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

Microsoft EndPoint Management

Sync ConfigMgr Collections to Intune

ConfigMgr collection sync is a feature that has been in ConfigMgr for a few versions. At a high level, it syncs the membership of a collection to a group in Entra ID that can then be

Read More »
WME Microsoft 365 Updates No. 025
Azure

WME Microsoft 365/Azure Updates 22 August 2025

1. Exchange Online: Temporary Mailbox Access Disruption via MAPI Overview Some Exchange Online users experienced mailbox access issues via the Messaging API (MAPI) on August 20, 2025. The disruption occurred after Microsoft reverted a recent service

Read More »