From: Nicholas Aquino
The System OU Collection Creator Script is a visual basic script that will create SMS collections based on the System_OU_Name0 information acquired from SMS via the Active Directory System Group Discovery.
The script queries the System_System_OU_Name_ARR table inside SQL. For each distinct object returned (each unique System_OU_Name0 value), a WMI method is called to SMS that will create a query based collection of clients with that particular System_OU_Name0 value.
When a collection is created, the following instance rights are added to the collection for the username who launched the script:
Read
Delete
Modify
Advertise
ViewCollectedFiles
ReadResource
In addition to the user's rights, the script will also add any group that resides in the local SMS Admins group to the instance permissions with the above rights as long as the group name is the same as the last OU listed in the System_OU_Name0 value.
For example:
The discovery method reported that a client resided in contoso.com\NorthAmerica\Building100.
There is a group called contoso\Building100 in the local SMS Admins group on the primary server.
The group contoso\building100 would be added to the instance permissions with the rights that are listed above.
The script echoes out each System OU Name as it is being created, so launching using cscript.exe is preferred. The command line is as
follows:
Cscript.exe SystemOUCollectionCreator.vbs <ServerName> <ParentCollectionID> <site code>
ParentCollectionID is the collection ID of the collection where all of the System OU collections will reside. If you would like these collections at the root, simply specify collroot as the ParentCollectionID.
The script will also produce a log file named SystemOUCollectionCreator.log so that you can reference all the newly created collections.
It is recommended that a scheduled task be created to launch this script under the Primary's System account. If run on a schedule, new System OU data will be queried automatically and a collection will be created.
Have Fun!
Nicholas Aquino
Systems Engineer - Asset & Configuration Management