Export-CMCollection
Export a collection.
Syntax
Export-CMCollection
[-ExportComment <String>]
-ExportFilePath <String>
[-Force]
-Name <String>
[-DisableWildcardHandling]
[-ForceWildcardHandling]
[-WhatIf]
[-Confirm]
[<CommonParameters>]
Export-CMCollection
-CollectionId <String>
[-ExportComment <String>]
-ExportFilePath <String>
[-Force]
[-DisableWildcardHandling]
[-ForceWildcardHandling]
[-WhatIf]
[-Confirm]
[<CommonParameters>]
Export-CMCollection
[-ExportComment <String>]
-ExportFilePath <String>
[-Force]
-InputObject <IResultObject>
[-DisableWildcardHandling]
[-ForceWildcardHandling]
[-WhatIf]
[-Confirm]
[<CommonParameters>]
Description
Use this cmdlet to save a collection object to a managed object format (.mof
) file.
You can then import it to the same or a different Configuration Manager site. You can use this export/import process to backup custom collections, or for development lifecycle. For example, you develop a new collection in a lab environment. Export the collection from the test environment, and then import it into the production hierarchy.
For more information, see How to manage collections in Configuration Manager.
Note
Run Configuration Manager cmdlets from the Configuration Manager site drive, for example PS XYZ:\>
. For more information, see getting started.
Examples
Example 1: Export a collection by name
This command exports the collection named testUser to the file named collection.mof.
Export-CMCollection -Name "testUser" -ExportFilePath "C:\collection.mof"
Example 2: Export all collections
This example first uses the Get-CMCollection cmdlet to get all collections, and stores them in the allColl variable. It then loops through each collection, and exports it to a separate file. It uses the collection name ($coll.Name
) as the file name.
$allColl = Get-CMCollection
foreach ( $coll in $allcoll ) {
Export-CMCollection -InputObject $coll -ExportFilePath "D:\Export\Collections\$($coll.Name).mof"
}
Parameters
-CollectionId
Specify the ID of a collection to export. This value is the CollectionID property, for example, XYZ00012
.
Type: | String |
Position: | Named |
Default value: | None |
Required: | True |
Accept pipeline input: | False |
Accept wildcard characters: | False |
-Confirm
Prompts you for confirmation before running the cmdlet.
Type: | SwitchParameter |
Aliases: | cf |
Position: | Named |
Default value: | False |
Required: | False |
Accept pipeline input: | False |
Accept wildcard characters: | False |
-DisableWildcardHandling
This parameter treats wildcard characters as literal character values. You can't combine it with ForceWildcardHandling.
Type: | SwitchParameter |
Position: | Named |
Default value: | None |
Required: | False |
Accept pipeline input: | False |
Accept wildcard characters: | False |
-ExportComment
Specify an optional comment for the exported collection in the MOF file.
Type: | String |
Position: | Named |
Default value: | None |
Required: | False |
Accept pipeline input: | False |
Accept wildcard characters: | False |
-ExportFilePath
Specify the full path for the export file. Include the file extension .mof
.
Type: | String |
Aliases: | FileName, FilePath, Path |
Position: | Named |
Default value: | None |
Required: | True |
Accept pipeline input: | False |
Accept wildcard characters: | False |
-Force
Run the command without asking for confirmation.
Type: | SwitchParameter |
Position: | Named |
Default value: | None |
Required: | False |
Accept pipeline input: | False |
Accept wildcard characters: | False |
-ForceWildcardHandling
This parameter processes wildcard characters and may lead to unexpected behavior (not recommended). You can't combine it with DisableWildcardHandling.
Type: | SwitchParameter |
Position: | Named |
Default value: | None |
Required: | False |
Accept pipeline input: | False |
Accept wildcard characters: | False |
-InputObject
Specify a collection object to export. To get this object, use the Get-CMCollection, Get-CMDeviceCollection, or Get-CMUserCollection cmdlets.
Type: | IResultObject |
Position: | Named |
Default value: | None |
Required: | True |
Accept pipeline input: | True |
Accept wildcard characters: | False |
-Name
Specify the name of a collection to export.
Type: | String |
Position: | Named |
Default value: | None |
Required: | True |
Accept pipeline input: | False |
Accept wildcard characters: | False |
-WhatIf
Shows what would happen if the cmdlet runs. The cmdlet doesn't run.
Type: | SwitchParameter |
Aliases: | wi |
Position: | Named |
Default value: | False |
Required: | False |
Accept pipeline input: | False |
Accept wildcard characters: | False |
Inputs
Microsoft.ConfigurationManagement.ManagementProvider.IResultObject
Outputs
System.Object