Remove a computer from a Collection when OSD Task Sequence is completed


I find a very interesting post where indicate how to put out of a collection a new computer after to be created with OSD.

The post is writed by Jörgen Nilsson.



When using a mandatory OSD advertisement to install a Operating system it is a great benefit to remove the computer from the Collection to where the OS deployment is advertised. The OSD task sequence advertisement can then be set to always rerun and all problems related to reinstalling an existing computer is solved.

This can be achieved by using a status filter rule together with a VBscript which removes the computer from the collection once the Task Sequence completes successfully.

I have updated the script to search for active computer records in SCCM using the name and then removing the computer from the collection using the ResourceID instead of using the name for matching. I have seen at customers that some third party applications created direct memberships with a different naming convention than the SCCM Admin Console does, this updated script will solve this problem.

Update 2
The script have been updated with the possibility to enter more than one collection to remove the computer from, it can also write an event to the event-log on the SCCM server with the name of the computer and the collection/collections it will be removed from.
I have removed the script code from this blog and made it available as a file instead, to avoid problems when cut/pasting the text.

You can download it here:

Download the script and save it as “remove.vbs”  edit the following line with the collection/collections you want the computer removed from

sCollectionIDs = “00100053:0010004A:00100069″

when that is done, complete the steps below to configure the status filter rule.


Configuring the status filter rule:

  1. Under site settings create a new status filter rule
  2. Configure it to use the following settings:

Component : Task Sequence Manager
Message Id: 11171

Run a Program: cscript.exe e:\sccmtools\remove.vbs %msgsys

Status1 status filter rule 2

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


Export pfx certificate with certutil through vbscript

These days I´m in a desktop migration project from XP to W7 and I need to export the user certificates of all 9.000 desktops…

For that I create a vbs than do it but by the other hand it can´t do all, the export to file of the serial number of all certificates is done with a batch script.

Here I put the vbs and the batch file.

VB Script

Dim shell

Set shell = CreateObject(“WScript.Shell”)

shell.Run “\\server\share\VolcadoCert.bat”

WScript.Sleep 10000

Const ForReading = 1
Dim strTemp
Dim CertID
Set objFSO = CreateObject(“Scripting.FileSystemObject”)

Set objFile = objFSO.OpenTextFile(“\\private user folder\certs.txt”, ForReading)

Do Until objFile.AtEndOfStream
strSearchString = objFile.ReadLine
strTemp = Mid(strSearchString, 1, 15)

if (strTemp = “Serial Number: “) then

CertID = Mid(strSearchString, 15, len(strSearchString)-14)

shell.Run “certutil.exe -user -p 12345678 -exportpfx ” & CertID & “\\private user folder\certificat” & cstr(replace(replace(replace(now(), “/”, “”),”:”, “”),” “, “”)) & “.pfx”, 1, false

end if



certutil -user -store “My” >> \\private user folder\certs.txt