Automating Creation of SCCM Collections

Recently we worked on a project where System Center Configuration Manager (SCCM) software deployments target collections of Active Directory (AD) Users and Groups instead of computer systems.  The client already had automated processes and workflows to facilitate the delivery of applications.

One process relied on a web interface to choose an AD group to be targeted for a particular application.  The customer requested a script that could be called from the Web application in a way that the AD group name could be passed as an argument, and the script would automatically create the collection with two dynamic queries: one relying on the User table and one on the UserGroup table to populate the collection with the members of the group and with the group itself.  In addition, another parameter would be passed that indicated if the collection should be created under the Licensed parent collection or under the Non-Licensed parent collection.  One last request was that if the AD group name started with “XX “ then strip that out, and if it started with “YYY “ then strip that out before using it as the collection name.

The script was developed.  To use it, the SCCM administrator must set the following variables at the beginning of the script:

  1. The collection ID for the parent Licensed collection
  2. The collection ID for the parent Non-licensed collection
  3. The name of the SCCM site server where the collection will be created

The script takes two arguments.  The first argument is the AD group name wrapped in double quotes (as it may contain spaces).  The second argument identifies the license type.  If “None” is passed then it is considered a non-licensed application; any other value indicates a licensed application.  This determines if the collection gets created as a child of the Licensed or Non-Licensed parent collection.

In line number 46, the NetBIOS domain name is added at the start of the value stored in the strColName variable (which is the name of the AD group).  In this case the domain name is “DOMAIN” followed by two backslashes (one extra backslash to account for the escape sequence).  This name can be modified depending on the domain name that the AD group belongs to.

Syntax example to call the script:

Cscript.exe CreateCol.vbs “My Group Name” Licensed

Share:

Facebook
Twitter
LinkedIn

Contact Us

=
On Key

More Posts

Be assured of everything

Get WME Services

Stay ahead of the competition with our Professional IT offerings.

=