I wrote a post a long while ago which started as question in on Technet Forum on how to remove a computer from a collection using a status filter rule once the OS deployment Task sequence is successful, I posted the script here: https://ccmexec.com/2010/03/remove-a-computer-from-a-collections-when-osd-task-sequence-is-completed/.
I still use it in almost all of my implementations of Configuration Manager. In one customer scenario I had to clear the PXE flag as well so I added that to the script so now you can select if you want the script to clear the PXE flag as well on the client when it is removed from the OS deployment collection.
The script works fine both in Configuration Manager 2007 and Configuration Manager 2012.
Why using a Status Filter Rule instead of a script in the TS run from the client side? Well you don’t have to open any firewall ports in the server for WMI e.t.c. You could also implement Webservices which do the same task for you, i like the simpleness in the status filter rule though.
The script can be downloaded here: Vbscript remove from Collection
To implement it:
1. Download the script and save it as “remove.vbs” in for instance E:\sccmtools or another folder on the Primary Site server.
2. Edit the following line with the collection/collections you want the computer removed from
sCollectionIDs = “00100053:0010004A:00100069″
You can now also configure if you want the script to clear the pxeflag by changing this value.
ClearLastPxe = “1”
You can also have the script to write to the eventlog on the Primary Site Server which Computername will be removed from which collections if you need to troubleshoot.
sEventlog = “1”
When that is done, save the file
3. Create a status filer rule, this screenshots are from Configuration Manager 2012 not that much differs.
4. Create a new status filter rule under Site Configuration\Sites choosing Status Filter rules.
5. Select Create
6. Configure it to use the following settings:
Name: Remove From Collection
Component : Task Sequence Manager
Message Id: 11171
Note: You have to type in “Task Sequence Manager” it is not available in the drop-down list as it is not a server component.
7. Run a Program: C:\windows\System32\cscript.exe e:\sccmtools\remove.vbs %msgsys
8. The next screen confirms that you are finished.
Now you have successfully implemented the Status Filter rule and can start testing.
Excellent site! I must be one of the few who can get this to run successfully. It seems quite straight forward. I modified the script to designate two collections. I created the filter on SCCM 2007 SP2 R3, and I pointed the remove.vbs to temporary folder on the C: drive. I must be missing something for it to run. I have tested the script on Windows XP deployment and USMT Migration from XP to Win7 with no success.
It should not matter if the collection is a sub-collection of another? I am specifying the collection id in where the computer is a direct member. Well back to testing
Good job on the script. Exactly what I was looking for.
Hi,
I cannot seem to get the vbs script to remove the machine from the collection manually.
vbs location – C:\StatusFilters\remove.vbs
Collections – sCollectionIDs = “C0100020:C010001F”
CMD line – cscript.exe \\servername\c$\StatusFilters\remove.vbs %msgsys
The script looks like it is running successfully in CMD but the machine remains in both Collections. The user I am logged on to server with has full SCCM admin rights.
Regards,
Tim
Hi,
Do you run it manually using the “cscript.exe \\servername\c$\StatusFilters\remove.vbs %msgsys”? in order to test it that way you need to replace %msgsys with the computername to remove.
/Jörgen
I got it working, was a group policy setting blocking communications between my machines and SCCM server!
Thank you for the response though.
Regards,
Tim
Hi Jörgen
Great solution, however I am seeing an interesting situation under CM2012. If more than one TS completes within the script sleep time (5 mins), it seems that only the first completion status is actioned. No adittional TS completion status messages (11171) can run the script until the first completes. So if five machines complete their build within a 5 minute window, only the first will be successfully removed from the identified collections.
Cheers
Jeff
I think I’m running into the same issue that Tim Hinchey did. I can run the script manually and the PC is removed from the collection. I double checked my Status Filter Rule many times and I know I have it setup correctly, but it’s not kicking off the script. Tim, what GPO settings were blocking communication between your machines and the SCCM server? Think I’m having the same issue.
Hi Jörgen
I have also the same issue like Jeff Du-Shane. Is there a solution?
Great solution but I experience one little problem:
The desktop is removed from the collection ….. but after the client rebooted and picked up the policy again. This is causing the client to install for a second time.
Anyone else with this problem (and hopefully a solution)?
Hi Jörgen
I have also the same issue like Jeff Du-Shane. Is there a solution?
Thanks for sharing the great script! One question — Is it possible to set this script to only trigger after specific task sequences? I guess even if it runs after every TS, it will only affect the designated collections, but I’d prefer for the script not to even trigger unless it was a certain TS that completed.
I really like this idea, but as with Steve I would prefer it to only run after a specific task sequence.
I’ve tried similar scripts that run from the task sequence itself but with little success.
You can use the filter rules to filter package or advertisement id. You just need to choose the Source first (being the Mgr server).
Hello and thank you for the script!
I can not get it to work on my CM 07 or on my CM 2012.
I have copyed the script to the server and everything seems to be working when i run the script form the command prompt.
How can i se what is not working? is there any loggin function i can use?
thx again
hi, please confirm if the value 0 or 1 to clear the pxe flag. thanks.
Hi,
The value should be 1
/Jörgen
I am having the very same issue as the first person who posted here. Will this script work with a direct membership in a sub-collection? I cannot get the script to work locally on the server, So I imagine its something to do with this?
Hello,
I’m using SCCM 2012 R2 to perform the deployment of Windows (OSD to unknown computers).
Everything is configured and working correctly.
Important: I use SCCM to just make the deployment of Windows (I do not I manage servers via SCCM).
The problem I have is: If a user attempts to rerun the OSD (Reinstalling Windows), I need to manually enter the SCCM and delete the computer in the collections (For the unknown computer became known after the task sequence) .
Do you have any suggestions?
I do not necessarily need the agent in SCCM servers (though it is necessary for the procedure OSD). So I get a service running unnecessarily.
Furthermore, this problem have to remove the computers, so that a procedure can be re OSD executed.
Good Afternoon,
We have multiple collections that deploy our task sequence but when I run this script if I put in more than one collection it will only run on the first collection listed in the script, not sure what is up with that.
Thank You
I am trying this to work with SCCM 1511 on Server 2012 R2 but it is not working.
I have a command as C:\windows\System32\cscript.exe \\Share\Scripts\remove.vbs %msgsys but it is not working.
When I run it manually C:\windows\System32\cscript.exe Share\Scripts\remove.vbs ComputerName it works.
Monitoring Reports: 11171 Success The task seqence manager successfully completed execution of the task sequence.
I have followed the instructions exactly as described here.
This script does not work all the time on our SCCM 1606 infra. The ID 11171 always appears, but on some clients the ID 30016 modify collection message appears and some not.
We cannot pinpoint the cause of the different behavior. Are there others with this issue?
I belive this is causing a delay in ou status message queues. We are currently in a large migration 200K devices. When this is running we are seeing delays of between 10 – 50 seconds in the statsmgr.log file. This is causing a large backlog of messages in out statmgr.box\statmsgs folder.
has anyone else seen this issue before
Hi,
I can run this script manually from my site server and it works but it doesn’t work as a filter I run it from the server it self so just use C:\windows\System32\cscript.exe c:\scripts\ColRem.vbs %msgsys I’ve changed the script name to ColRem.vbs.
Found out it was only not working for newly imported devices and i’ve fixed it by changing the below line by adding or Obsolete is null.
Set arrComputers = SWbemServices.ExecQuery(“select * from SMS_R_System where Name='” & strComputerName & “‘ and (Obsolete = 0 or Obsolete is null)”)