Month: January 2015

Quick tip: Excluding times in SCO Monitor Date/Time

Posted on Updated on

If your System Center 2012 R2 Orchestrator runbooks are triggered using the Monitor Date/Time activity, it may be necessary at times to exclude another specific time.  In a recent scenario for a customer, there was the risk of two related (but disparate) runbooks conflicting with each other.  Their schedules each had them running at the beginning of the hours (at the :00 minute).  So to prevent a collision, I set up the link to exclude that time of the hour.  This is a quick time on how you can approach this as well.

The image below illustrates the monitor activity is set to run every 30 minutes.

SCOQT1a

Next, the image below illustrates the link from the monitor.  In the published data, ensure you’ve selected the checkbox to show common published data, then select item “Activity end time (minutes)”.

SCOQT1b

Finally, set the value for the activity end time to 00, which indicates the top of the hour.  So now in this example, the runbook will only execute fully at the 30th minute!

SCOQT1c

Advertisement

Script to delete any Drive:\smspkg\*.pck files of the specified file age

Posted on Updated on

There are many scripts and examples out there for cleaning up PCK files.  The below script is my rendition to cleanup PCK files that are older than the specified number of days.  This script can be executed via a package in ConfigMgr on systems that are a DP.  Oh and I added some basic logging to the script as well :-)


' Script to delete any Drive:\smspkg\*.pck files of the specified file age
sLogFile = "c:\windows\temp\dp_pck_cleanup.log"
iFileAge = 365

Set oFSO = CreateObject ("Scripting.FileSystemObject") 
Set oOutputFile = oFSO.OpenTextFile (sLogFile, 8, True) 
Set oWMI = GetObject("winmgmts:\\.") 
Set colItems = oWMI.ExecQuery("SELECT * FROM Win32_LogicalDisk") 

oOutputFile.WriteLine "******** PCK cleanup began ********  " & Date

For Each oDrive in colItems 
	sDrive=left(oDrive.caption,1) 
	'wscript.echo "sDrive: " & sDrive
	If (oFSO.FolderExists(sDrive & ":\smspkg\")) Then    
		oOutputFile.WriteLine "Smspkg exists on drive " & sDrive
		Set receive = oFSO.GetFolder(sDrive & ":\smspkg\") 
		Set colFiles = receive.Files 
		
		For Each oFile in colFiles 
			sFileName=(lcase(oFile))
			'wscript.echo sFileName
			If (right(sFileName, 4) = ".pck") then 
				'wscript.echo "This is a PCK file"
				If DateDiff("d", oFile.DateLastModified, Date) > iFileAge Then 
					oOutputFile.WriteLine oFile & " exists with modified date: " & oFile.DateLastModified & ", Size (MB):" & vbtab & int(oFile.Size/1048576) 
					oFSO.DeleteFile oFile,TRUE 
					oOutputFile.WriteLine "      Deleted successfully "
				End If 
			End If 
		Next 
	Else
		oOutputFile.WriteLine "No smspkg folder on " & sDrive
	End If 
Next