Trigger Compliance evaluation

Compliance and remediation (Desired configuration) can be triggered from the UI on the workstation.

This script runs on a remote system and triggers the process for all configuration settings on a workstation.  It integrates directly into MUSCE.

[VBSCRIPT code]
' Purpose: Trigger SCCM client to run the compliance configuration

if WScript.Arguments.Count < 1 then
  wscript.echo "Missing argument. Expected HOSTNAME"
  wscript.quit 1
end if

S = ""

' Process the init request for startup
if  WScript.Arguments.Item(0) = "Init" then
	S = S & "[Requires]PingTest=Yes" & vbCrLf
	S = S & "[Requires]Wait=" & 15 * 1000 & vbCrLf 		' requires "x" seconds to complete
	wscript.echo S
	wscript.quit 0
end if

HostName = WScript.Arguments.Item(0)

' read the available configurations
strQuery = "SELECT * FROM SMS_DesiredConfiguration"
Set objWMIService = GetObject("winmgmts:\\" & HostName & "\ROOT\ccm\dcm")
Set colItems = objWMIService.ExecQuery(strQuery, "WQL", wbemFlagReturnImmediately + wbemFlagForwardOnly)
if isObject(colItems) then
	For Each objItem in colItems
		with objItem
			'S = S & "Name " & i & "="  & .Name & vbcrlf
			'S = S & "Name " & i & "="  & .Version & vbcrlf
			
			' trigger the action
			set objCCM_CU = objWMIService.Get("SMS_DesiredConfiguration")
			ReturnValue = objCCM_CU.TriggerEvaluation(.name,.version)
			If ReturnValue = 0 then
				S = S & "Response=Valid" & vbCrLf
			Else
				S = S & "Response=Invalid" & vbCrLf
			End if

		end with
	Next
End if
WScript.Echo S
wscript.quit 0

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

w

Connecting to %s