If you want to create many software Metering rules then you can use this code. This function uses CSV file to import data.



Function Create-Rule{            
    Param(            
         $strRuleFileLocation,            
         $strComputer,            
         $strSiteCode            
    )            
                
    Try{            
        #Check if file exists            
        If(Test-Path $strRuleFileLocation){            
    }            
    #Import CSV file            
    $strRuleFileImport = Import-Csv $strRuleFileLocation



foreach ($item in $strRuleFileImport){ $strMeteredProductRuleClass = "SMS_MeteredProductRule" # WMI Class $strColon = ":" #Create Connection $strWMIConnection = [WmiClass]"\\$strComputer\ROOT\SMS\$strSiteCode$strColon$strMeteredProductRuleClass" #Create Instance $strCreateRule = $strWMIConnection.psbase.CreateInstance() #Set Values $strCreateRule.ProductName = $item.ProductName $strCreateRule.FileName = $item.FileName $strCreateRule.OriginalFileName = $item.OriginalFileName $strCreateRule.FileVersion = $item.FileVersion $strCreateRule.LanguageID = $item.LanguageID $strCreateRule.SiteCode = $item.SiteCode $strCreateRule.ApplyToChildSites = $item.ApplyToChildSites $strCreateRule.Enabled = $item.Enabled $strCreateRule.Put() } } Catch{ Write-Host "Please Specify correct file location" } } # End Function Create-Rule

Author: Kaido Jarvemets
Configuration Manager MVP, MCITP, MCTS
Blog: Depsharee.blogspot.com