Weekly Tip 66

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″]

Share:

Facebook
Twitter
LinkedIn

Contact Us

Name
=
On Key

More Posts

WME Cybersecurity Briefings No. 040
Cyber Security

WME Security Briefing 04 August 2025

1. NightEagle APT Exploits Zero-Day in Microsoft Exchange to Target Chinese Defense and Tech Sectors Overview A new advanced persistent threat group, dubbed NightEagle (also called APT-Q-95), is being linked to a string of attacks. These

Read More »
Be assured of everything

Get WME Services

Stay ahead of the competition with our Professional IT offerings.

=