Friday, November 20, 2015

Script powerShell to create user Category for catalogue SCCM 2012

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

Here's 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\root\SMS\Site_$($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 "Root\SMS\Site_$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
}


No comments:

Post a Comment

Note: Only a member of this blog may post a comment.