Back Up & Restore SCCM Custom Collections
This guide walks you through backing up and restoring custom collections in Microsoft Endpoint Configuration Manager (SCCM), ensuring your carefully built device and user groupings survive a site failure, migration, or accidental deletion. You’ll learn two reliable methods—PowerShell export/import and WMI-based backup—and how to restore collections on a new or existing site. Before starting, you need administrative access to the SCCM site server or a machine with the Configuration Manager console and PowerShell module installed.
What You’ll Need
- Administrative rights on the SCCM site server or a machine with the Configuration Manager console.
- PowerShell with the Configuration Manager module (usually available after installing the console).
- Access to the SCCM site database (for WMI method) or a location to store exported XML files.
- A test environment to verify the restore process before applying it to production.
Step-by-Step
Method 1: PowerShell Export and Import (Recommended)
- Open PowerShell as Administrator on a machine with the SCCM console installed. Import the Configuration Manager module by running:
Import-Module "$env:SMS_ADMIN_UI_PATH\..\ConfigurationManager.psd1". - Connect to the site by changing to the site drive (e.g.,
PS:\> Set-Location PS:\SMS\YourSiteCode). ReplaceYourSiteCodewith your actual site code. - Identify your custom collections. Run
Get-CMCollection | Where-Object {$_.IsBuiltIn -eq $false}to list all collections that are not built-in. Note theCollectionIDorNamefor each one you want to back up. - Export each collection using the
Export-CMCollectioncmdlet. For example:Export-CMCollection -Name "All Windows 10 Laptops" -FilePath "C:\Backup\collections\Win10Laptops.xml". Repeat for each custom collection, or use a loop to export all at once. - Verify the export files are created and contain XML data. Open one file in a text editor to ensure it includes the collection rules and query expressions.
- To restore on a new or existing site, copy the XML files to the target machine. Open PowerShell, import the module, and connect to the target site drive.
- Import the collection using
Import-CMCollection -FileName "C:\Backup\collections\Win10Laptops.xml". This recreates the collection with its original name, comments, and refresh schedule. If the collection already exists, you’ll need to delete it first or use the-Forceparameter (if supported in your version) to overwrite. - Verify the import by running
Get-CMCollection -Name "All Windows 10 Laptops"to confirm it exists and its membership rules are intact.
Method 2: WMI Backup (For Full Site Recovery)
- Back up the site database using SQL Server backup or the built-in SCCM backup task. This captures all collections, including custom ones, as part of the database.
- If you only need collection definitions (not full membership), you can query WMI on the site server. Use PowerShell to connect to the
Root\SMS\site_<SiteCode>namespace and retrieve collection objects fromSMS_Collection. - Export the collection data to a file using a script that serializes the WMI objects. For example:
Get-WmiObject -Namespace "Root\SMS\site_ABC" -Class SMS_Collection | Export-Clixml "C:\Backup\collections.xml". - To restore, import the XML file back into WMI using
Import-Clixmland then recreate each collection by setting the appropriate properties on a newSMS_Collectioninstance. This is more complex and error-prone; use the PowerShell cmdlets if possible.
Common Mistakes
- Forgetting to include dependent collections – custom collections often reference other custom collections in their limiting collection or query rules. Ensure you back up all related collections, not just the top-level ones.
- Exporting built-in collections – Built-in collections (like “All Systems”) should not be exported or imported; they are recreated automatically. Filter them out as shown.
- Ignoring collection variables – If your collections have collection variables (e.g., for OSD), the standard export may not include them. You’ll need to document and recreate them manually.
- Importing to a different site code – The XML contains the site code; importing to a site with a different code may cause errors. Edit the XML or use a script to update the site code if necessary.
- Not testing the restore – Always test the backup and restore in a lab environment to ensure the process works before relying on it in a disaster.
Tips
- Schedule regular backups – Use a PowerShell script to export all custom collections to a network share on a weekly basis. This ensures you have a recent copy.
- Include collection comments – Add a comment to each collection describing its purpose; this helps during restore to verify the correct collection is imported.
- Use a naming convention – Prefix custom collections with something like “CUS-” to easily distinguish them from built-in ones.
- Document your collections – Maintain a spreadsheet or documentation listing collection names, limiting collections, query rules, and any variables. This is invaluable if the export fails.
- Leverage the console – You can also right-click a collection in the SCCM console and choose “Export” to save it as a MOF file. This is a quick manual method for a few collections.
Troubleshooting
- Import fails with “Collection already exists” – Delete the existing collection first (if it’s not needed) or use the
-Forceparameter if available. Be cautious, as deleting a collection removes its membership. - PowerShell module not loading – Ensure you are running PowerShell as Administrator and that the SCCM console is installed on the machine. The module path may vary; check the console installation directory.
- Export produces an empty file – Verify the collection name is correct and that you are connected to the right site drive. Run
Get-CMCollectionto see available collections. - Restored collection has no members – The collection’s query rules are restored, but membership updates take time. Trigger a manual update by right-clicking the collection and selecting “Update Membership”.
- WMI restore fails – WMI-based restore is fragile. Prefer the PowerShell cmdlets. If you must use WMI, ensure the site server is healthy and the SMS Provider is running.
- Site code mismatch – Edit the exported XML to replace the old site code with the new one using a text editor or PowerShell script before importing.
Frequently Asked Questions
Can I back up collections without the SCCM console?
Yes, you can use WMI directly on the site server or query the SQL database, but it’s more complex. The easiest method is to use the PowerShell module, which requires the console to be installed on the machine you’re using.
Does the export include collection members?
No, the export only includes the collection definition (name, query rules, limiting collection, refresh schedule). Membership is recalculated after import based on the current device/user inventory.
Can I restore a collection to a different site in the same hierarchy?
Yes, as long as the site code is updated in the XML or you use the -Force parameter. The collection will be created as a new collection with the same rules.
What about subcollections?
Subcollections are collections that have another collection as their limiting collection. You must export and import them as well, ensuring the parent collection is imported first.
Is there a built-in backup feature for collections?
SCCM’s site backup includes the database, which contains all collections. However, for a quick export/import of just collections, the PowerShell cmdlets are the most practical.
How often should I back up my collections?
It depends on how often you create or modify collections. A weekly backup is a good starting point, but if you make frequent changes, consider daily or after each major change.
Related
Method: the standard formula for this calculation, rounded as each result states. See how the calculators work or report an error.