Displaying Advertisement Property Flags in ConfigMgr 2007

I recently wrote some VBScript code to be used in connecting to the Provider on a ConfigMgr 2007 site in order to manipulate the various radio buttons and checkboxes on the different tabs of the Advertisement Properties dialog box. Several of the settings are controlled by RemoteClientFlags and AdvertFlags properties in the SMS_Advertisement WMI class.

It is always helpful to refer to the SMS_Advertisement Server WMI Class page found at http://msdn.microsoft.com/en-us/library/cc146108.aspx. That page contains a lot of great information about the different values. It is part of a larger library of information that is very helpful in scripting against the SMS Provider. But while the information is very helpful, I really wanted an easier way to look at which flags were set in the RemoteClientFlags (RCF) and AdvertFlags (ADV) properties.

So I wrote a little script. The script evaluates all of the adverts configured on a site server and outputs them to a file that lists the property, the hex value, and the flag (bit) description. The output format starts with the Advertisement Name followed by a list of the flags. As shown below, each line contains the data/time stamp, RCF or ADV to indicate which property the flag is part of, the bit for each flag, the flag description, and a 1 or 0 to indicate if it is set or not.

With this script it is easy to see which flags are set. Manually change things in the Advertisement Properties dialog and re-running the script allow you to see what flags change and can help with seeing which flags are associated with each item. This script outputs the flags set for every advert, but it can be easily modified to limit the logging to specific advertisements. By default the log is written to C:\Windows\Temp\FlagEval.log

Once you know what flags you want to set or clear you simply refer to the bit as 2^# (where the bit # is identified in the FlagEval log). For example, to enable Wake on LAN for a package you would add 2^22 to the AdvertFlags property of the package’s instance in the SMS_Advertisement class.

I am going to post the script here, but first you should know that you have to be careful when using a script to set values in the SMS Provider involves Lazy Properties. That’s a topic for another day

FlagEval.vbs

' 1E Ltd Copyright 2012
'
' Disclaimer:
' Your use of this script is at your sole risk. This script is provided "as-is", without any warranty, whether express
' or implied, of accuracy, completeness, fitness for a particular purpose, title or non-infringement, and is not
' supported or guaranteed by 1E. 1E shall not be liable for any damages you may sustain by using this script, whether
' direct, indirect, special, incidental or consequential, even if it has been advised of the possibility of such damages.
Option Explicit
Dim strComputer, strLogText, strLogFile, strTempdir, xLocation, colItems, WshShell
Dim objWMIService, objItem, objSWbemLocator, objProviderLocation, objFSO
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set WshShell = WScript.CreateObject("WScript.Shell")
strTempdir = WshShell.ExpandEnvironmentStrings("%systemroot%") & "\temp\"
strComputer = "."
Set objSWbemLocator = CreateObject("WbemScripting.SWbemLocator")
Set objWMIService = objSWbemLocator.ConnectServer(strComputer, "root\sms")
Set objProviderLocation = objWMIService.InstancesOf("SMS_ProviderLocation")
For Each xLocation In objProviderLocation
If xLocation.ProviderForLocalSite = True Then
Set objWMIService = objSWbemLocator.ConnectServer(xLocation.Machine, "root\sms\site_" + xLocation.SiteCode)
Exit For
End If
Next
If objFSO.FileExists(strTempdir & "FlagEval.log") Then objFSO.DeleteFile(strTempdir & "FlagEval.log")
Set colItems = objWMIService.ExecQuery("SELECT * FROM SMS_Advertisement")
For Each objItem in colItems
WriteLog("-------------------------------------------------")
WriteLog(objItem.AdvertisementName)
WriteLog("-------------------------------------------------")
If objItem.RemoteClientFlags AND 2^3 Then
WriteLog("RCF3: RUN_FROM_LOCAL_DISPPOINT: 1")
Else
WriteLog("RCF3: RUN_FROM_LOCAL_DISPPOINT: 0")
End If
If objItem.RemoteClientFlags AND 2^4 Then
WriteLog("RCF4: DOWNLOAD_FROM_LOCAL_DISPOINT: 1")
Else
WriteLog("RCF4: DOWNLOAD_FROM_LOCAL_DISPOINT: 0")
End If
If objItem.RemoteClientFlags AND 2^5 Then
WriteLog("RCF5: DONT_RUN_NO_LOCAL_DISPPOINT: 1")
Else
WriteLog("RCF5: DONT_RUN_NO_LOCAL_DISPPOINT: 0")
End If
If objItem.RemoteClientFlags AND 2^6 Then
WriteLog("RCF6: DOWNLOAD_FROM_REMOTE_DISPPOINT: 1")
Else
WriteLog("RCF6: DOWNLOAD_FROM_REMOTE_DISPPOINT: 0")
End If
If objItem.RemoteClientFlags AND 2^7 Then
WriteLog("RCF7: RUN_FROM_REMOTE_DISPPOINT: 1")
Else
WriteLog("RCF7: RUN_FROM_REMOTE_DISPPOINT: 0")
End If
If objItem.RemoteClientFlags AND 2^8 Then
WriteLog("RCF8: DOWNLOAD_ON_DEMAND_FROM_LOCAL_DP: 1")
Else
WriteLog("RCF8: DOWNLOAD_ON_DEMAND_FROM_LOCAL_DP: 0")
End If
If objItem.RemoteClientFlags AND 2^9 Then
WriteLog("RCF9: DOWNLOAD_ON_DEMAND_FROM_REMOTE_DP: 1")
Else
WriteLog("RCF9: DOWNLOAD_ON_DEMAND_FROM_REMOTE_DP: 0")
End If
If objItem.RemoteClientFlags AND 2^10 Then
WriteLog("RCF10: BALLOON_REMINDERS_REQUIRED: 1")
Else
WriteLog("RCF10: BALLOON_REMINDERS_REQUIRED: 0")
End If
If objItem.RemoteClientFlags AND 2^11 Then
WriteLog("RCF11: RERUN_ALWAYS: 1")
Else
WriteLog("RCF11: RERUN_ALWAYS: 0")
End If
If objItem.RemoteClientFlags AND 2^12 Then
WriteLog("RCF12: RERUN_NEVER: 1")
Else
WriteLog("RCF12: RERUN_NEVER: 0")
End If
If objItem.RemoteClientFlags AND 2^13 Then
WriteLog("RCF13: RERUN_IF_FAILED: 1")
Else
WriteLog("RCF13: RERUN_IF_FAILED: 0")
End If
If objItem.RemoteClientFlags AND 2^14 Then
WriteLog("RCF14: RERUN_IF_SUCCEEDED: 1")
Else
WriteLog("RCF14: RERUN_IF_SUCCEEDED: 0")
End If
' **************************************
If objItem.AdvertFlags AND 2^5 Then
WriteLog("ADV5: IMMEDIATE: 1")
Else
WriteLog("ADV5: IMMEDIATE: 0")
End If
If objItem.AdvertFlags AND 2^8 Then
WriteLog("ADV8: ONSYSTEMSTARTUP: 1")
Else
WriteLog("ADV8: ONSYSTEMSTARTUP: 0")
End If
If objItem.AdvertFlags AND 2^9 Then
WriteLog("ADV9: ONUSERLOGON: 1")
Else
WriteLog("ADV9: ONUSERLOGON: 0")
End If
If objItem.AdvertFlags AND 2^10 Then
WriteLog("ADV10: ONUSERLOGOFF: 1")
Else
WriteLog("ADV10: ONUSERLOGOFF: 0")
End If
If objItem.AdvertFlags AND 2^15 Then
WriteLog("ADV15: WINDOWS_CE: 1")
Else
WriteLog("ADV15: WINDOWS_CE: 0")
End If
If objItem.AdvertFlags AND 2^17 Then
WriteLog("ADV17: DONOT_FALLBACK: 1")
Else
WriteLog("ADV17: DONOT_FALLBACK: 0")
End If
If objItem.AdvertFlags AND 2^18 Then
WriteLog("ADV18: ENABLE_TS_FROM_CD_AND_PXE: 1")
Else
WriteLog("ADV18: ENABLE_TS_FROM_CD_AND_PXE: 0")
End If
If objItem.AdvertFlags AND 2^20 Then
WriteLog("ADV20: OVERRIDE_SERVICE_WINDOWS: 1")
Else
WriteLog("ADV20: OVERRIDE_SERVICE_WINDOWS: 0")
End If
If objItem.AdvertFlags AND 2^21 Then
WriteLog("ADV21: REBOOT_OUTSIDE_OF_SERVICE_WINDOWS: 1")
Else
WriteLog("ADV21: REBOOT_OUTSIDE_OF_SERVICE_WINDOWS: 0")
End If
If objItem.AdvertFlags AND 2^22 Then
WriteLog("ADV22: WAKE_ON_LAN_ENABLED: 1")
Else
WriteLog("ADV22: WAKE_ON_LAN_ENABLED: 0")
End If
If objItem.AdvertFlags AND 2^23 Then
WriteLog("ADV23: SHOW_PROGRESS: 1")
Else
WriteLog("ADV23: SHOW_PROGRESS: 0")
End If
If objItem.AdvertFlags AND 2^25 Then
WriteLog("ADV25: NO_DISPLAY: 1")
Else
WriteLog("ADV25: NO_DISPLAY: 0")
End If
If objItem.AdvertFlags AND 2^26 Then
WriteLog("ADV26: ONSLOWNET: 1")
Else
WriteLog("ADV26: ONSLOWNET: 0")
End If
WriteLog(" ")
Next
' **********************************************************************************************************************
Sub WriteLog(strLogText)
strLogText = Now() & " " & strLogText
Set strLogfile = objFSO.OpenTextFile(strTempdir & "FlagEval.log",8,True) ' 2=New, 8=Append
strLogfile.WriteLine strLogText
strLogfile.Close
End Sub

In the role of Senior Consultant at 1E, John is responsible for the design and implementation of 1E products for our customers. He has been working in the IT field for the past 20 years. He started out with ADP working with DOS/Windows 3.1 and has moved on to both in-house and consulting roles over the years, working with both Windows and Macintosh computers, Active Directory, several different SAN and virtualization products, and systems management software starting with SMS 1.2.
John lives in northwestern New Jersey with his wife of 25 years, Lillian, and their two children Kerrie and Angel.