A PowerShell module is build for export and importing SCCM collections. Default SCCM PowerShell cmdlts can export and import collections but this will be mof files. This PowerShell module can export all collections and maintaining the folder structure.
The module will import and export:
Requirements
Initialize
$SCCMSiteCode = "P01" #location of the CM_Collection PowerShell module $InstallDir = "C:\PowerShell" #Default installation path of ConfigurationManager Powershell module Import-Module "C:\Program Files (x86)\Microsoft Configuration Manager\AdminConsole\bin\ConfigurationManager.psd1" Import-Module "$InstallDir\CM_Collections.psd1"
$SCCMSiteCode = "P01" #location of the CM_Collection PowerShell module $InstallDir = "C:\PowerShell" #Default installation path of ConfigurationManager Powershell module Import-Module "C:\Program Files (x86)\Microsoft Configuration Manager\AdminConsole\bin\ConfigurationManager.psd1" Import-Module "$InstallDir\CM_Collections.psd1"
#Export all collections Export-CMCollectionsToXML > "$InstallDir\ExportSCCMCollections.XML" #Export all Device Collections from the folder GEN Export-CMDeviceCollectionsToXML "GEN" > "$InstallDir\SCCMCollections\ExportSCCMDeviceCollectionsGEN.XML"
#Export all collections Export-CMCollectionsToXML > "$InstallDir\ExportSCCMCollections.XML" #Export all Device Collections from the folder GEN Export-CMDeviceCollectionsToXML "GEN" > "$InstallDir\SCCMCollections\ExportSCCMDeviceCollectionsGEN.XML"
#Import All Collections from file $importFile Import-CMCollectionsFromXML $ImportFile #Import All Device Collections from file $importFile Import-CMDeviceCollectionsFromXML $ImportFile #Import All User Collections from file $importFile Import-CMUserCollectionsFromXML $ImportFile
#Import All Collections from file $importFile Import-CMCollectionsFromXML $ImportFile #Import All Device Collections from file $importFile Import-CMDeviceCollectionsFromXML $ImportFile #Import All User Collections from file $importFile Import-CMUserCollectionsFromXML $ImportFile