Export SCCM Device Collection using PowerShell

In this post I will show you how to export SCCM device collection using PowerShell. Using Export-CMCollection PowerShell command, you can export the device collection in ConfigMgr.

Other than using PowerShell, there are multiple methods to export a device collection in Configuration Manager.

For example, you can manually export a device collection using SCCM console. To do that you have to enter each collection and select the devices and then copy the data and paste to excel.

In fact the easiest way to export devices from a collection is to open your collection, select the devices, do a Ctrl+C and then open excel and past the clipboard contents.

Exporting a device collection here means you export all the devices within that collection to an excel file that can be analyzed later.

It is always good thing to export the device collection when you want to compare two device collections.

Export SCCM Device Collection using PowerShell

Let’s see how to export SCCM device collection using PowerShell:

  • Launch the ConfigMgr console.
  • In the upper-left corner, there’s a blue rectangle. Select the white arrow in the blue rectangle, and choose Connect via Windows PowerShell.
  • To export the device collection run the PowerShell command.
Export-CMCollection -Name "Device_collection_name" -ExportFilePath "path to .mof file"

Export-CMCollection PowerShell cmdlet is exclusively used to export a device collection. The collection exported here is in .mof format.

You must provide an export file path and specify where you want to save the .mof file. You can use the same .mof file to import the device collection in case the collection is deleted.

Export SCCM Device Collection using PowerShell
Export SCCM Device Collection using PowerShell

Note: You can use ConfigMgr reports to find the devices that are part of a device collection. Reports in SCCM have an export option that will export the device details to different file formats.

In the SCCM console, go to Monitoring\Overview\Reporting\Reports. From the list of all reports, look for the report named “All resources in a specific collection“. Right-click this report and select Run.