How to import existing computer objects to a SCCM 2012 collection with PowerShell

 Sometimes you need to add a lot of different already existing computer objects to a Configuration Manager collection.

 If you are lucky, these objects are placed in another collection or in a AD group, BUT – what if you just got a specific list of computers from someone ells that they would like to have updated with a certain application?

 Instead of adding the computer objects manually to the SCCM collection membership, you can add all object to an existing collection using Configuration Manager 2012 PowerShell.

 First: Create a collection in SCCM with the name you like

 Second: save the list of computers in a 1 column CSV file with the computer names only, remove all other information.

PowerShellComputers

 Third: Run this script and change the CSV file name and path and SCCM Collection Name.

$computers = Get-Content “c:\temp\computers.csv” | foreach {Add-CMDeviceCollectionDirectMembershipRule -CollectionName “COLLECTION NAME HERE” -ResourceId $(get-cmdevice -Name $_).ResourceID}

 At Last: Run this PowerShell script in the Configuration Manager Console PowerShell windows – at your own risk –  and please test with a single computer object first!

SCCMConsolePowerShell

I hope this tip will help you save some time.

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 )

Google+ photo

You are commenting using your Google+ 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 )

Connecting to %s