Showing posts with label script. Show all posts
Showing posts with label script. Show all posts

Monday, September 5, 2016

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

Read more »

Thursday, August 4, 2016

Script powerShell to create user Category for catalogue SCCM 2012

Script powerShell to create user Category for catalogue SCCM 2012


You have a list of category to implemente on System configurqtion Manager 2012 r2.

Heres a script powershell that will do it for you :





Function Create-AdministrativeCategory
{
    [CmdLetBinding()]
     Param(
 
    [Parameter(Mandatory=$True,HelpMessage="Please Enter Category Name")]
              $CategoryInstanceName
         )

   
              $SiteCode = "Site code"
             $SiteServer = "SCCM Server"
 
         
 

    #New GUID for the Category
    $GUID = [GUID]::NewGuid().ToString()

    #Create the SMS_Category_LocalizedProperties property
    $NewCat = ([WMIClass]"$SiteServer ootSMSSite_$($SiteCode):SMS_Category_LocalizedProperties").CreateInstance()
    $NewCat.CategoryInstanceName = $CategoryInstanceName
    $NewCat.LocaleID = 0

    #Create the New Category Instance
    $Arguments = @{CategoryTypeName = "CatalogCategories"; LocalizedInformation = [ARRAY]$NewCat; SourceSite = $SiteCode;CategoryInstance_UniqueID = "CatalogCategories:$GUID"}
    Try{
        Set-WmiInstance -Namespace "RootSMSSite_$SiteCode" -Class "SMS_CategoryInstance" -ComputerName $SiteServer -Arguments $Arguments
    }
    Catch{
        $_.Exception.Message
    }  
}

#List of category to add for web catalog
$PrdAppList = @("Free application","Windows 10 Applications","Virtual applications","Windows 7 to windows 10","Licenced applications","Downloaded applications","Iphone applications","Adroid applications","Windows Phone applications","Microsoft Applications","Security Applications")

foreach ($PrdApp in $PrdAppList)
{
    Create-AdministrativeCategory -CategoryInstanceName $PrdApp
}


Available link for download

Read more »