WMI Class which signifies what adverts allow clients to fall back to unprotected distribution points?

Greetings All,

Our organization is looking to enable a few unprotected distribution points (currently we are %100 protected).  I was working with our Client Engineering team today to prepare for this to ensure we do not cause problems related to network traffic.

One thing that I noticed is that in our advertisements, we have "Allow clients to fall back to unprotected distribution points when the content is not available on the protected distribution point." enabled on some advertisements and disabled on others.

Instead of going through each advertisement manually to disable this (talking 100's) feature, I would like to possibly run a powershell script that will identify those advertisements that have this setting "enabled" via a particular CM07 WMI class.  I have fished around a bit on MSDN http://msdn.microsoft.com/en-us/library/cc142995.aspx ,  but perhaps am looking in the wrong place?

As a bonus, I would like to disable this setting for all of our advertisements, so that our Client Engineering team can go back and manually enable it for just those adverts/packages that they want to have fall back to the unprotected DP.

If anyone can point me in the right direction, that would be appreciated.

Regards,

Pat


January 3rd, 2014 7:30pm

It's specified using a binary flag in the AdvertFlags attribute of the SMS_Advertisement class: http://msdn.microsoft.com/en-us/library/cc146108.aspx
Free Windows Admin Tool Kit Click here and download it now
January 3rd, 2014 8:55pm

And if memory serves me right this is the one that is really easy to break when setting it with a script. Something to do with lazy properties. I'm no scripter.

January 3rd, 2014 10:02pm

It's easy break if you don't know what a binary flag is or how to set/remove one so, yeah, exactly why I pointed that out. You can't simply assign a decimal value, you must remove the binary flag using binary arithmetic which is easily done using binary operators. Lazy properties also play a part; MSDN has a nice little page on those as well: http://msdn.microsoft.com/en-us/library/cc146672.aspx
Free Windows Admin Tool Kit Click here and download it now
January 3rd, 2014 10:09pm

Okay good to know and thanks for the quick responses.  

I spoke with my scripting SME regarding this and he feels comfortable with dealing with binary flags.  We are going to start with just a query first.  I will update this thread when I have news!

January 3rd, 2014 11:30pm

I actually have this somewhere. I wasn't able to find it and I'd be nervous about posting it. I totally screwed a site up doing this once. The only time I can remember that I actually had to restore from a backup.

Free Windows Admin Tool Kit Click here and download it now
January 3rd, 2014 11:54pm

Just a quick additional note, binary flags have nothing to do with scripting, it's just a way to store on/off switches (aka flags) using a very small memory footprint. You pretty much handle them the same way in any programming language.

As a side note, you really shouldn't have a scripting SME -- scripting is an important skill in *every* admins toolbox. It's a differentiator between you and those "clicky-clicky" admins.

January 3rd, 2014 11:56pm

I hear you Jason...and my scripting career is a work in progress. I just like to work with someone who has a much stronger scripting background than myself, so I don't end up pooching our central site.  I don't feel the need to do a site repair/restore to ring in the New Year.  

As it stands we may not even go this route, especially considering the consequences if done incorrectly.

So with that being said, we should still be able to query WMI to find this information just to identify those adverts that have "fall back to unprotected DP" enabled with little or no consequence, correct?

Also, if we are just viewing the properties of the advertisement, I would think that this information also resides within a view on the DB as well?  If I were to guess by your initial statement it would be in v_Advertisement.AdvertFlags?  I should be able to pull this same information via SQL, correct?  At least with that we can identify the adverts that have it enabled.

Free Windows Admin Tool Kit Click here and download it now
January 5th, 2014 8:22am

Correct, both are valid ways to query the info but only WMI is a valid and supported way to modify the flag.
January 5th, 2014 10:38pm

Here is a simple SQL query to view values for the relevant Advertflag (based on http://msdn.microsoft.com/en-us/library/cc146108.aspx) :

SELECT ADV.AdvertisementID, 
  ADV.AdvertisementName, 
  (AdvertFlags & 0x00020000)/0x00020000 AS DONOT_FALLBACK 
FROM dbo.v_Advertisement ADV

To learn about scripting changes to values , a decent starting place is the SMS 2003 Recipes that you can browse the contents using google books(http://books.google.co.uk/books?id=14hWq8NNggwC&pg=PA226&lpg=PA226&dq=sms+2003+recipies+RemoteClientFlags&source=bl&ots=KeBJspdpKO&sig=8AG7uY7BORX17DOsTTevuCkqIZw&hl=en&sa=X&ei=z-7GUrWeEJDT7AbZgYHQCA&ved=0CC8Q6AEwAA#v=onepage&q=sms%202003%20recipies%20RemoteClientFlags&f=false). Almost of the material is still relevant to ConfigMgr 2007.  Below is an vbs example based on the samples in that book (you will need to change <SiteServer> to your site server) that may help you get started:

Option Explicit

Const wbemFlagForwardOnly = 32

' Do not fall back to unprotected Distribution Pointss 
Dim DONOT_FALLBACK 
DONOT_FALLBACK = 2^(17)

If WScript.Arguments.Count < 1 Then
	WScript.Echo "Usage:"
	WScript.Echo "    DisableFallbackToUnprotectedDP.vbs -all"
	WScript.Echo "    DisableFallbackToUnprotectedDP.vbs AdvertisementID [AdvertisementID]..."
	WScript.Quit
End If

Dim strSiteServer
Dim colItems
Dim objItem
Dim AdvertisementID
Dim blnItemFound
Dim intAdvertisements
Dim intUpdated

strSiteServer = <SiteServer>

Dim objLoc, objSMS, Results, Loc
Set objLoc = CreateObject("WbemScripting.SWbemLocator")
Set objSMS= objLoc.ConnectServer(strSiteServer, "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)
	End if
Next

If StrComp(UCase(WScript.Arguments.Item(0)), "-ALL", 1) = 0 Then
	intAdvertisements = 0
	intUpdated = 0
	Set colItems = objSMS.ExecQuery("SELECT * FROM SMS_Advertisement", "WQL", wbemFlagForwardOnly)
	For Each objItem in colItems
		If (objItem.AdvertFlags AND DONOT_FALLBACK) = 0 Then
			objItem.AdvertFlags = objItem.AdvertFlags OR DONOT_FALLBACK
			objItem.Put_
			intUpdated = intUpdated + 1
			WScript.Echo "Modified Advertisement " & objItem.AdvertisementID
		End If
		intAdvertisements = intAdvertisements + 1
	Next
	WScript.Echo "Updated " & intUpdated & " of " & intAdvertisements & " advertisement"
Else
	For Each AdvertisementID in WScript.Arguments
		Set colItems = objSMS.ExecQuery("SELECT * FROM SMS_Advertisement WHERE AdvertisementID='" & AdvertisementID & "'", "WQL", wbemFlagForwardOnly)
		blnItemFound = false
		For Each objItem in colItems
			If (objItem.AdvertFlags AND DONOT_FALLBACK) = 0 Then
				objItem.AdvertFlags = objItem.AdvertFlags OR DONOT_FALLBACK
				objItem.Put_
				WScript.Echo "Modified Advert " & objItem.AdvertisementID
			Else
				WScript.Echo "No need to update Advert " & objItem.AdvertisementID
			End If
			blnItemFound = true
		Next
		If blnItemFound = false Then
			WScript.Echo "ERROR: Advertisement " & AdvertisementID & " was not found on Site Server " & strSiteServer
		End If
	Next
End If

Free Windows Admin Tool Kit Click here and download it now
January 6th, 2014 3:07pm

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics