System Center Configuration Manager 2012 R2 remove computer object from Collection when Task Sequence is complete

A Task Sequence deployment in SCCM can be set to Required to start the deployment without any user interaction (F12 etc.). Also the rerun behavior can be set to Always rerun program to keep running the deployment until the object (Resource) is removed from the collection.
These two options make it easy to (re)start a new deployment from within SCCM by adding the Resource to the Collection.

But… the option Always rerun program will rerun the Task Sequence until the resource is removed from the Collection. Removing the Resource after a Task Sequence is finished is not a default option within SCCM, but using the following guide and script it is possible. The script will also write an output to a log file so by checking the file or check if the Resource is still member of the Collection it is possible to check if the Task Sequence is finished.

 

Download the script here

Extract the zip file to a (network) location. image
Open the Remove.VBS file with a text editor image
Start the SCCM console and find the Collection ID of the Collection where the Resource must be deleted from when the deployment is finished imageimage
Go back to the VBS script in the editor and add the Collection ID’s in the sCollectionIDs section image
Change the location of the log files image
Optional: Change the filename of the log file image
Save the VBS file
Start the SCCM console
Click on Administration image
Click on Sites image
Click on Status Filter Rules image
Click on Create image
Enter a name, for example: Remove computer from OSD collectionsEnter the Message ID 111171

Click Next

image
Select Report to Event Log

Select Run a Program
Enter C:\windows\System32\cscript.exe C:\remove.vbs %msgsys

(Change the script location if necessary, a network location is also possible as long as SCCM can access the file)Click on Next and finish the Wizard

image
The result looks like this: imageimage

Add a Resource to the Collection and start the Task Sequence, check if the Resource is remove when the Task Sequence is finished. It is also possible to check the log file to see if the script has succesfully ran.

Advertisements
This entry was posted in System Center and tagged . Bookmark the permalink.

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 )

Twitter picture

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

Facebook photo

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

Google+ photo

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

Connecting to %s