How to Refresh the Compliance State of the SCCM computer clients


if you have machines that not update their compliance state on SCCM 2007… for example, 200 machines that not say what did with some update deployments… you can execute the following vbs:

Sub RefreshServerComplianceState()

    ' Initialize the UpdatesStore variable.
    dim newCCMUpdatesStore 

    ' Create the COM object.
    set newCCMUpdatesStore = CreateObject ("Microsoft.CCM.UpdatesStore")

    ' Refresh the server compliance state by running the RefreshServerComplianceState method.

    ' Output success message.
    wscript.echo "Ran RefreshServerComplianceState."

End Sub



How to create a task Schedule that execute a bat file

In Vista/Seven/2008/2008R2 it´s hard to configure a task schedule that execute bat or vbs files…

With this settings you can!

Create a vbs that does runas administrator:

set WshShell = WScript.CreateObject(“WScript.Shell”) “runas /user:domain\user %comspec%” ‘Open command prompt 
WScript.Sleep 1000 
WshShell.SendKeys “password” ‘send password 
WshShell.SendKeys “{ENTER}” 
WScript.Sleep 1000

Set objApp = CreateObject(“WScript.Shell”) “D:\Scripts_TaskSchedulers\LATAM.cmd” ‘execute the bat or cmd file
Set wshshell = nothing

Create a new task shcedule that go to find the new vbs.

It´s all!

Import pfx certificate with certutil through vbscript

After I have exported all certificates with private key I developed this script that import all pfx in the user´s personal store.

Set objFSO = CreateObject(“Scripting.FileSystemObject”)
Set shell = CreateObject(“WScript.Shell”)
Const ForAppending = 2
Dim objFSO:Set objFSO = CreateObject(“Scripting.FileSystemObject”)

objStartFolder = “C:\Temp”

Set objFolder = objFSO.GetFolder(objStartFolder)

Dim ext

ext = “”

Set colFiles = objFolder.Files
For Each objFile in colFiles
ext = Mid(objFile.Name, len(objFile.Name) – 3, len(objFile.Name))
if (ext=”.pfx”) then “certutil.exe -user -p 12345678 -importpfx c:\temp\” & objFile.Name
end if