Configuration Items that I would like to export and import
Here are some command examples that we can use in Configuration Manager 2012 R2 CU4.
#Import Module Import-Module $env:SMS_ADMIN_UI_PATH.Replace("\bin\i386","\bin\configurationmanager.psd1") $SiteCode = Get-PSDrive -PSProvider CMSITE Set-Location "$($SiteCode.Name):\" #Get all CIs $ConfigurationItems = Get-CMConfigurationItem #Total CIs $ConfigurationItems.Count #Get CIs only with specific keyword $ConfigurationItems = Get-CMConfigurationItem -Name "*CT - *" -ForceWildcardHandling #CI rules with 'CT - ' keyword - 12 CIs in this example $ConfigurationItems.Count #Export out CIs with 'CT - ' keyword foreach($CI in $ConfigurationItems){ Write-Output -InputObject "Exporting out $($CI.LocalizedDisplayName) CI" Export-CMConfigurationItem -Path "$env:USERPROFILE\Desktop\CI_Rules\$($CI.LocalizedDisplayName).cab" -InputObject $CI } #New CI folder New-Item -Path "$($SiteCode.Name):\ConfigurationItem" -Name Coretech #Import CIs $ExportedConfigurartionItems = Get-ChildItem 'D:\CI_Rules' -Filter *.cab* foreach($ECI in $ExportedConfigurartionItems){ #Import CI Import-CMConfigurationItem -FileName $ECI.FullName -Force #Get the new CI $NewCI = Get-CMConfigurationItem -Name $ECI.BaseName #Move the CIs to correct folder Move-CMObject -FolderPath "$($SiteCode.Name):\ConfigurationItem\Coretech" -InputObject $NewCI } #Create new Baseline New-CMBaseline -Name "Coretech Baseline" -Description "Just for Demo" #Add CIs to new Baseline $CI1 = Get-CMConfigurationItem -Name "CT - Pending Reboot - File Rename Operations" $CI2 = Get-CMConfigurationItem -Name "CT - Pending Reboot - Software Updates" $CI3 = Get-CMConfigurationItem -Name "CT - Pending Reboot ConfigMgr Agent" Set-CMBaseline -Name "Coretech Baseline" -AddOSConfigurationItems $CI1.CI_ID,$CI2.CI_ID,$CI3.CI_ID #Deploy the Baseline Start-CMBaselineDeployment -CollectionName 'All Systems' -Name "Coretech Baseline"
Export Folder output
Happy Scripting