Export and important Application and packages from one primary to other primary sites

Question

Hi All,

Earlier we had one primary sites for multi domain however customer has segregated it to 6 primary sites for each domain. Hence we have 6 primary sites for each domain.

Sometimes application/ package created in a site will be used for all the primary sites. So I m looking for solution to get a script to export and import application for each PRIMARY SITE.

I would really appreciate if someone can share script or any solution which is already in place?

 

Thanks 😊

Kashif

Answers ( 3 )

  1. Yes, the script is one of the ways to achieve this.
    But I don’t have one ..but start from here https://www.deploymentshare.com/creating-a-configmgr-package-with-powershell/

    MIgration job is another option https://docs.microsoft.com/en-us/mem/configmgr/core/migration/planning-a-migration-job-strategy

      0
      2021-02-01T22:49:40+05:30

      Hi Anoop,

      Yes the migration job is there but we are looking for the option which we can use in future so that when we run script it export application and imports it to all 6 primary sites.

      I came across below script. Could check and confirm if I am in the right path.. Where I can add multiple destination sites in the script?

      https://github.com/Duffney/PowerShell/blob/master/SCCM/ConfigMgrTools/Migrate-CMApplication.ps1

      Thanks
      Kashif

    • I think you are on the right path. I don’t know much about this script and I never used it.

      my recommendation is to try this test environment and before trying it in production

        0
        2021-02-10T15:35:50+05:30

        Hi Anoop,

        This script works however it needs to be executed in each primary sites as there is no CAS.

        So wondering if someone has any script which can be executed in one primary site and application/package gets created in all the primary sites?

        It would be a great help.

        Thanks in advance

        • I have not seen anything like that yet…

            0
            2021-02-10T21:09:34+05:30

            Below is the script. In the script you need to add destination site code and destination fqdn in new-psdrive line.

            Function Migrate-CMApplication {

            [CmdletBinding()]

            param (

            [Parameter(Mandatory=$True,HelpMessage=”Enter the source sitecode.”)]

            [Alias(‘Source’)]

            [String]$SourceSiteCode,

            [Parameter(Mandatory=$True,HelpMessage=”Enter the destination sitecode.”)]

            [Alias(‘Destination’)]

            [String]$DestinationSiteCode,

            [Parameter(Mandatory=$True,HelpMessage=”Enter the export location.”)]

            [String]$ExportLocation,

            [Parameter(Mandatory=$True,HelpMessage=”Enter the name of the ConfigMgr Application.”)]

            [Alias(‘Application Name’)]

            [String[]]$LocalizedDisplayName

            )

            BEGIN{

            }

            Process{

            Try

            {

            $Export = $True

            Write-Verbose “Connecting to $SourceSiteCode…”

            Import-Module “$(Split-Path $env:SMS_ADMIN_UI_PATH -Parent)\ConfigurationManager.psd1” -ErrorAction Stop

            Set-Location “$($SourceSiteCode):”

            }

            Catch [System.IO.FileNotFoundException]

            {

            $Export = $false

            Write-Error “SCCM Admin Console not installed”

            }

            Catch

            {

            $Export = $false

            $ErrorMessage = $_.Exception.Message

            $FailedItem = $_.Exception.ItemName

            }

            If ($Export) {

            Write-Verbose “Exporting $LocalizedDisplayName…”

            $LocalizedDisplayName = (Get-CMApplication | Where-Object {$_.LocalizedDisplayName -like “*$LocalizedDisplayName*”}).LocalizedDisplayName

            Export-CMApplication -Path “$ExportLocation\$LocalizedDisplayName.zip” -Name “$LocalizedDisplayName” -OmitContent -IgnoreRelated

            }

            Try

            {

            $Import = $True

            Write-Verbose “Connecting to $DestinationSiteCode…”

            Import-Module “$(Split-Path $env:SMS_ADMIN_UI_PATH -Parent)\ConfigurationManager.psd1” -ErrorAction Stop

            New-Psdrive -Name [DestinationSitecode] -PsProvider “AdminUI.PS.Provider\CMSite” -Root “Destination server FQDN”

            Set-Location “$($DestinationSiteCode):”

            }

            Catch [System.IO.FileNotFoundException]

            {

            $Import = $false

            Write-Error “SCCM Admin Console not installed”

            }

            Catch

            {

            $Import = $false

            $ErrorMessage = $_.Exception.Message

            $FailedItem = $_.Exception.ItemName

            }

            If ($Import){

            Write-Verbose “Importing $LocalizedgetDisplayName…”

            Import-CMApplication -FilePath “$ExportLocation\$LocalizedDisplayName.zip”

            }

            Try

            {

            Write-Verbose “Moving app to Vendor folder”

            $CMApplication = Get-CMApplication -Name $LocalizedDisplayName

            Set-Location .\Application

            $Vendor = (Get-CMApplication -Name $LocalizedDisplayName).Manufacturer

            New-Item -Name $Vendor | Out-Null

            Move-CMObject -FolderPath $Vendor -InputObject $CMApplication -ErrorAction Stop | Out-Null

            cd ..

            }

            Catch [System.InvalidOperationException]

            {

            Move-CMObject -FolderPath $Vendor -InputObject $CMApplication -ErrorAction Stop | Out-Null

            cd ..

            }

            Catch

            {

            $ErrorMessage = $_.Exception.Message

            $FailedItem = $_.Exception.ItemName

            }

            }

            }

            Best answer

Leave an answer

Sorry, you do not have permission to answer to this question .