Getting a list of protected DPs in your hierarchy


I was recently asked if there was a way, via the SDK, to list out all your protected DPs and their configured boundaries.  I found that this information is available using the SDK but not easily accessible.  I have attached a script that is an example of how to do this.  It lists out all DPs in your hierarchy, identifies whether they are protected, and then lists any configured boundaries.


-Russ


‘Rslaten 03/2006
‘Gets protected DPs
‘Pass Central site server as first argument
‘Needs more error checking added

WScript.Echo “”
WScript.Echo “GetProtectedDPs”
WScript.Echo “Usage: cscript.exe GetProtectedDPs.vbs <CenSiteServerName>”
WScript.Echo “Example: cscript.exe GetProtectedDPs.vbs myCentralSiteServer”
WScript.Echo “”

‘Globals
Dim oServices

Main

Sub Main
On Error Resume Next
Dim sNameSpace, sSiteServer, sSiteCode, oLocator
sSiteServer = WScript.Arguments(0)
sNameSpace = GetSMSNameSpace(sSiteServer)
sSiteCode = Right(sNameSpace, 3)
Set oLocator = CreateObject(“WbemScripting.SWbemLocator”)

‘Connect to WMI
Set oServices = oLocator.ConnectServer(sSiteServer, sNameSpace,,,,,128)
If Err.number <> 0 Then
WScript.Echo “Error connecting to “ &sNameSpace& ” on “ &WScript.Arguments(0)& “: “ &Err.Number
Set oLocator = Nothing
Set oServices = Nothing
WScript.Quit
End If

‘Refresh SCF
RefreshSCF(sSiteCode)

‘QueryDPs
QueryDPs(sSiteCode)
End Sub

‘Queries DPs
Sub QueryDPs(sSiteCode)
Dim collDP, oRes, sStart, aProps, oProp, aPropList, oPropList, oValue
Set collDP = oServices.ExecQuery(“select * from sms_sci_sysresuse where SiteCode = ‘”&sSiteCode&“‘”)
For each oRes in collDP
If oRes.RoleName = “SMS Distribution Point” Then
sStart = InStr(oRes.NALPath,“=\\”) + 3
sFinish = InStr(oRes.NALPath,“]MSWNET”) – 2
sDP = mid(oRes.NALPath,sStart,sFinish-sStart)
WScript.Stdout.Write sDP
aProps = oRes.Props
aPropList = oRes.PropLists
For each oProp in aProps
If oProp.PropertyName = “IsProtected” Then
If oProp.Value = 1 Then
WScript.Stdout.Write ” (Protected)” & vbCrLf
Else
WScript.Stdout.Write ” (UnProtected)” & vbCrLf
End If
End If
Next
For each
oPropList in aPropList
If oPropList.PropertyListName = “Protected Boundary” Then
For each oValue in oPropList.Values
Select Case oValue
Case “IP Subnets”
WScript.Stdout.Write vbTab & “Protected Boundary – IP Subnet: “
Case “AD Site Name”
WScript.Stdout.Write vbTab & “Protected Boundary – AD Site Name: “
Case “IP Ranges”
WScript.Stdout.Write vbTab & “Protected Boundary – IP Ranges: “
Case Else
WScript.Stdout.Write oValue & vbCrLf
End Select
Next
End If
Next
End If
Next
Set
collDP = Nothing
End Sub

‘Refreshes site control in WMI
Sub RefreshSCF(sSiteCode)
On Error Resume Next
Dim sQry, colSysRes
sQry = “select * from SMS_SiteControlFile where FileType = 1 and SiteCode = ‘” &sSiteCode& “‘”
Set colSysRes = oServices.ExecQuery(sQry)
If Err.number <> 0 Then
WScript.Echo “Unable to query SMS Provider”
WScript.Echo “Query: “ & sQry
WScript.Echo “Error = “ & Err.number & ” – “ & Err.Description
WScript.Quit
End If
For each SCI in colSysRes
SCI.Refresh
Next
Set
colSysRes = Nothing
End Sub

‘Gets SMS Namespace
Function GetSMSNameSpace(SiteServer)
On Error Resume Next
Dim colNameSpaceQuery, refitem, refWMI
Set refWMI = GetObject(“winMgmts:\\” &SiteServer&“\root\sms”)
If Err.number <> 0 Then
WScript.Echo “Error connecting to SMS namespace on “ &SiteServer
WScript.Quit
End If
Set colNameSpaceQuery = refWMI.ExecQuery(“select * from SMS_ProviderLocation”)
For Each refitem in colNameSpaceQuery
GetSMSNameSpace = refitem.NamespacePath
Next
Set colNameSpaceQuery = Nothing
Set refitem = Nothing
Set refWMI = Nothing
End Function

GetProtectedDPs.zip

Comments (1)

  1. Summary: SMS 2003 and ConfigMgr 2007 have an often useful feature called protected distributed points