Heres a Script PowerShell to duplicate Package on SCCM 2012

Heres a Script PowerShell to duplicate Package on SCCM 2012


Before Modify any Package on Production, take time to duplicate it.
Its a part of Best Practice, to duplicate a package befor modifing them.




Heres a Script PowerShell to duplicate Package on SCCM 2012

#------------------------

$ServerSCCM = "SCCMTest"
Import-Module $ServerSCCMd$Program FilesMicrosoft Configuration ManagerAdminConsole inConfigurationManager.psd1
$pkgID = FR100F40
$packageDestination = "ShareSoftRepository_Serveurs1. UATPackages"
$PackageList = @(gwmi -ComputerName $ServerSCCM -Namespace rootsmssite_FR1 -class SMS_Package -filter "PackageID=$pkgID")

if ( $PackageList.count -gt 0 ) {
         foreach ( $package in $PackageList )
         {
          #Store name and location of package
          $pName = $package.name
          $pLocation = $package.PkgSourcePath
        
          #Extract folder name of package
          $folderName =$pLocation.Substring($pLocation.LastIndexOf("")+1)
                  
          Write-Host "Package to duplicate : " $pName
          #Copie sources
          Copy-Item $pLocation  $packageDestination  -recurse
        
          #acces to SCCM site
          cd "$((Get-PSDrive -PSProvider CMSite).Name):"
        
          $ProgramList = Get-CMProgram -PackageId $pkgID
        
          #Create a copie of package
          $newPackage = New-CMPackage -Name "$pName - copie" -Path "$packageDestination$folderName"
          #add programes
          foreach ( $Program in $ProgramList )
          {
         
           $np = New-CMProgram -PackageName "$pName - copie"  -CommandLine $Program.CommandLine -StandardProgramName $Program.ProgramName
           #Copie program Proreities
           $np.ProgramFlags = $Program.ProgramFlags
         
           #Commit changes
           $np.put()
         
          }
        
   
        
                  
        
           }
      
                 
        }
 

Available link for download

download
alternative link download
Heres a Script PowerShell to duplicate Package on SCCM 2012 Heres a Script PowerShell to duplicate Package on SCCM 2012 Reviewed by renata on 7:11 AM Rating: 5