In this post, I will show you how to use CMPivot to find device domain name in SCCM. By running a simple KQL query, you can quickly identify machines connected to a specific domain and export the details to a CSV file.
I have seen organizations using an SCCM server to work for both domains in separate forests. Managing clients from different domains in Configuration Manager often requires identifying the domain each client is connected to. Instead of manually checking these details for every computer, you can efficiently gather this information using CMPivot.
CMPivot queries the data in real-time, so you get accurate results. One important thing to remember here is when you have a collection that contains devices from another site, CMPivot results include the devices on the current site unless CMPivot is run from the CAS.

Find machines connected to a specific domain with CMPivot
Here’s how you can run a CMPivot query to find domain information of Windows devices in a Configuration Manager environment. First, launch the SCCM console and navigate to Assets and Compliance > Overview > Device Collections. Right-click a device collection and select Start CMPivot.

Switch to the Query tab of the CMPivot tool. Paste the below query (replace the domain name with yours) into the query editor and click Run.
Device | where Domain == ('YOUR DOMAIN NAME')In the query results, the ‘Domain‘ column shows the domain name that devices are connected to.

If you want to find out the computers that aren’t joined to a specific domain, you can use the below CMPivot query.
Device | where Domain != ('Your Domain Name')Lastly, there is an export option in the CMPivot query window that allows you to export the device’s domain information to an external file (CSV file).



