Tuesday, January 7, 2014

Powershell to Add / Remove a PC To SCCM Collection

This is one of those fun things. To Add a PC to the Collection MS makes you do it by Resource ID.
This means you need to lookup the Resource ID of the PC, which you can do by Name, before you dump it in.
 
 ADD:
 $x="PCNAME";$collectionname="Collection";Add-CMDeviceCollectionDirectMembershipRule -CollectionName $collectionname -ResourceId $(get-cmdevice -Name $x).ResourceID   
 
Removal is Simpler, as you simply need to specify the PC name and Collection name. 
 
REMOVE:

 Remove-CMDeviceCollectionDirectMembershipRule -CollectionName <String> -ResourceName <String> [-Force]  

No comments:

Post a Comment