Share via


System Center Configuration Manager PowerShell Module

System Center Configuration is used in most of the organizations for Patch Management, Inventory Management etc., often it is important to retrieve the Systems, Servers and devices from SCCM. SCCM group the systems using collections ex: device by type ( server, workstation). here would like to describe a PowerShell module which will help to Add members in a collection quickly.

Below Have Explained Few Functions which will help to : 

1. Add Servers in a Text File to a Collection

2. Create SCCM Collection with Servers recognized by Wild Chars

3. Add Child Collection to a Parent Collection

Pre-Requisites :-

This Article PowerShell Scripts needs Configurationmanager powershell module to be imported into the Powershell script. This Module Helps to Communicate with Configuration Manger with Simple Command lets.

Import-Module $env:SMS_ADMIN_UI_PATH.Replace("\bin\i386","\bin\configurationmanager.psd1")

Module :-

  1. Add Servers in a Text File to a Collection

This Function takes four Parameters : SCCMSiteServerName, SiteCodeName,CollectionName,ServersList Path, LimitingCollectionName

Step#1: Creates a Collection With Limiting Collection Name - which allows new collection to choose any server that belongs to Limiting Collection and it limits the scope to only servers in Limiting Collection.

Step#2: Retrieves all the Servers in the Text File Path Provided as Arg 4.

Step#3: Adds all the Servers to the Collection - Retrives the ResourceIds of all the Servers and then adds those Resource ids to the New Collection.

2. Create SCCM Collection with Servers recognized by Wild Chars

    This Function takes 5 Parameters : SCCMSiteServerName, SiteCodeName,CollectionName,CollectionPath,WildCharString, LimitingCollectionName

Step#1 : This Script Changes the Current directory to the SCCM Admin Path and set location to the SiteCode.

Step#2 : Creates New Collection with Limiting Collection

Step#3 : Creates a Query String with the WildString Provided, which is used to retrieve the Servers which qualifies. In the Below Example all Servers which has POS in there Names.

Step#4 : Adds the Query String to the New Collection which intern adds all the Servers which qualifies Wild Chars

Step#5 : Although the Collection is Created with all the required Servers, the Collection will be placed at the Root Location of SCCM Collections which we need to Move explicitly. Move-CMObject Helps in Moving the collection to its requested Path.

3. Add Child Collection to a Parent Collection

This Function adds the Collection to an Another Collection which will add all the members of the Source Collection to Parent Collection. Though this is a straight forward command, would like to add to this module to complete the Module.

this Function takes two parameters : TargetCollectionName and SourceCollectionName

Step#1 : This Step will add SourceCollection to the Target Collection

Hope you Enjoyed the reading.

Thank You,

Vinod.