Sign up for 1E's newsletter:

How to add computers listed in a text file to a device collection

How to add computers listed in a text file to a device collectionUsing the new ConfigMgr 2012 PowerShell cmdlets, there are three different ways to add computers to a device collection. Just like in the console, you can add computers via a direct membership rule (Add-CMDeviceCollectionMembershipRule), a query membership rule (Add-CMDeviceCollectionQueryMembershipRule) and also an include collection membership rule (Add-CMDeviceCollectionIncludeMembershipRule). In order to use these cmdlets, the collection already needs to be created. In my previous post on my own blog, How to quickly create Collections using New-CMDeviceCollection, I demonstrated one way of creating device collections based off of a for loop and using each loop as an index number in the collection name.

In this post, since we will be reading a list of computers from a text file, we will use the direct membership rule cmdlet Add-CMDeviceCollectionMembershipRule to add them to the device collection. Using this cmdlet, you can add a device resource object to one or more device collections. Since collection names are unique in CM 12, it is easiest to reference the collection that you want to add objects to using the -CollectionName parameter.  For the device that we are trying to add, the easiest way is to get the resource ID and use the -ResourceId parameter. We can get the resource ID of a device called PC01 using the Get-CMDevice cmdlet.

Disclaimer:
Your use of these example scripts or cmdlets is at your sole risk. This information is provided “as-is”, without any warranty, whether express or implied, of accuracy, completeness, fitness for a particular purpose, title or non-infringement. I shall not be liable for any damages you may sustain by using these examples, whether direct, indirect, special, incidental or consequential. That said, enjoy!

Continue reading at Mike’s personal blog.

Mike Terrill | Systems Management Practice Lead

To explore this issue further, or discuss other industry challenges, contact us at info@1e.com, or join our LinkedIn forum, 1E INSIDEV1EW.

If you found this article helpful, please take a moment to share it with your contacts using the social media buttons to the left.


Mike Terrill

about Mike Terrill

Mike Terrill is Systems Management Practice Lead at 1E. He is focused on Windows Systems Management and Operating System Deployment using Microsoft technologies. Mike's specialism is in System Center 2012 Configuration Manager and he has been using this product since Systems Management Server (SMS) 1.2. Mike has designed, architected, implemented, and worked with some of the leading top Fortune companies. His current project is a global Configuration Manager implementation and Windows 7 deployment for a 450K seat environment. Mike is also the founder and user group leader for the Arizona Systems Management User Group (www.azsmug.org), and blogs at http://miketerrill.net

Would you like to share your thoughts?

Your email address will not be published.

Please type the characters of this captcha image in the input box





Press Esc to close

Copyright © 1E 2014 All Rights Reserved | Terms & Conditions | Privacy Policy

This website uses cookies to improve your experience. We'll assume you're ok with this. Privacy setting