Get Collections that use an OU as their Query Rule
This script will output, as a CSV file, the collection names and IDs of collections that are using an OU as their query.
Note: This script targets device-based collections. It can easily be modified for user by changing lines 6 and 25. Change the CollectionType from “2” to “1” in like 6, and change get-cmdevicecollectionquerymembershiprule to get-cmuserollectionquerymembershiprule in line 25.
Instructions:
Modify line 1 for your CSV file. Provide the path and file name.
Modify lines 2 and 3 to the name of your ConfigMgr primary site server and site code.
Mody line 30 to include the domain and OU that is being used in your queries, leaving the quotes and wildcards.
Example: if ($coll_query -like “*CONTOSO.COM/Desktops*”) {
Disclaimer
All content provided on this blog is for information purposes only. Windows Management Experts, Inc makes no representation as to accuracy or completeness of any information on this site. Windows Management Experts, Inc will not be liable for any errors or omission in this information nor for the availability of this information. It is highly recommended that you consult one of our technical consultants, should you need any further assistance.
[download id=”5157″]