The Source Code download for the SMS 2003 Recipes book provided a few example scripts for modifying the ProgramFlags Property of the SMS_Program class. By request, here's one more.
Here's how to script the process to enable the "Suppress program notifications" checkbox on the Advanced tab of a ConfigMgr program:
| SUPPRESS_PROGRAM_NOTIFICATIONS = 2^(10) strSMSServer = "MyServerName" strPackageID = "LAB0013D" 'enter packageID strProgramName = "My Test Program" 'enter Program Name Set objLoc = CreateObject("WbemScripting.SWbemLocator") Set objSMS= objLoc.ConnectServer(strSMSServer, "root\sms") Set Results = objSMS.ExecQuery _ ("SELECT * From SMS_ProviderLocation WHERE ProviderForLocalSite = true") For each Loc in Results If Loc.ProviderForLocalSite = True Then Set objSMS = objLoc.ConnectServer(Loc.Machine, "root\sms\site_" & _ Loc.SiteCode) strSMSSiteCode = Loc.Sitecode end if Next Set objProgram=objSMS.Get("SMS_Program.PackageID='" & _ strPackageID & "',ProgramName='" & strProgramName & "'") intProgramFlags = objProgram.ProgramFlags if (intProgramFlags and SUPPRESS_PROGRAM_NOTIFICATIONS) then wscript.echo "SUPPRESS_PROGRAM_NOTIFICATIONS flag " & _ "already set!" else wscript.echo "Setting SUPPRESS_PROGRAM_NOTIFICATIONS flag" intProgramFlags = intProgramFlags or _ SUPPRESS_PROGRAM_NOTIFICATIONS objProgram.ProgramFlags = intProgramFlags objProgram.Put_ end if |
And here's a simple PowerShell Example:
| $SUPPRESS_PROGRAM_NOTIFICATIONS = ([math]::pow(2,10)) $computerName = "MyServerName" $PackageID = "LAB0013D" $ProgramName = "My Test Program" $Prov = gwmi -class SMS_ProviderLocation -Namespace ROOT\SMS ` -Computer $ComputerName | where {$_.ProviderForLocalSite -eq "True"} $NS = "Root\SMS\Site_" + $Prov.SiteCode $b = gwmi sms_program -namespace $NS -computer $ComputerName ` | where {$_.PackageID -eq $PackageID -and $_.ProgramName -eq $ProgramName} $b.ProgramFlags = $b.ProgramFlags -bor $SUPPRESS_PROGRAM_NOTIFICATIONS $b.put() |
Greg
ramseyg@hotmail.com