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

Mastering Azure AD Connect - A Comprehensive Guide by WME
Active Directory

Mastering Azure AD Connect – A Comprehensive Guide

Modern businesses are fast moving toward cloud-based infrastructure. In fact, cloud-based business is not just a trend anymore but a strategic necessity. Microsoft’s Azure Active Directory (Azure AD) has become a frontrunner in this domain. It

Read More »
Security Best Practices in SharePoint
Office 365

Security Best Practices in SharePoint

Microsoft SharePoint is an online collaboration platform that integrates with Microsoft Office. You can use it to store, organize, share, and access information online. SharePoint enables collaboration and content management and ultimately allows your teams to

Read More »
The Ultimate Guide to Microsoft Intune - Article by WME
Active Directory

The Ultimate Guide to Microsoft Intune

The corporate world is evolving fast. And with that, mobile devices are spreading everywhere. As we venture into the year 2024, they have already claimed a substantial 55% share of the total corporate device ecosystem. You

Read More »
Protecting Microsoft 365 from on-Premises Attacks
Cloud Security

How to Protect Microsoft 365 from On-Premises Attacks?

Microsoft 365 is diverse enough to enrich the capabilities of many types of private businesses. It complements users, applications, networks, devices, and whatnot. However, Microsoft 365 cybersecurity is often compromised and there are countless ways that

Read More »
Be assured of everything

Get WME Services

Stay ahead of the competition with our Professional IT offerings.