Your company's ad could live here and reach over 50,000 people a month!

Share This Post

Finding ConfigMgr client install string in AD Schema

Have you ever wanted to verify that your client push properties were  correctly published in the AD schema?  I discovered this afternoon that  doing so is much more difficult than it should be.  The command line is  stored in the mSSMSCapabilities attribute of the SMS-MP-XXX-SERVERNAME attribute  in the System Management container.  To grab the full install string, I  created a script that takes the server name as a command line parameter (cscript  .\myscript.vbs MYSERVER), queries the server to find the site code and domain  name, then performs an LDAP query to retrieve the install string.  You  could obviously supply the site code and domain name to make it run much faster,  but I was more interested in reusability than speed.  Keep in mind that the  account that runs the script will need to have the appropriate rights…

Here’s the code snippet (as always, watch out for word-wrap [and smart-quotes]):

'Get server name as command line input
'————————————-
strServerName = WScript.Arguments.Item(0)
WScript.Echo "Server Name: " & strServerName

'Get SMS site code from server WMI
'———————————
Set objWMIService = GetObject("winmgmts:\" & strServerName & "\root\SMS")
Set colItems = objWMIService.ExecQuery( _
    "SELECT Name FROM __NAMESPACE " & _
    "WHERE Name LIKE 'site_%'", _
    "WQL", &h10 + &h20)
For Each objItem in colItems
    strSiteCode=Right(objItem.Name,3)
Next
WScript.Echo “Site Code: ” & strSiteCode

'Get domain from server WMI
'————————–
Set objWMIService = GetObject("winmgmts:\" & strServerName & "\root\CIMV2")
Set colItems = objWMIService.ExecQuery( _
    "SELECT DNSDomain " & _
    "FROM Win32_NetworkAdapterConfiguration " & _
    "WHERE DNSDomain > '' AND DNSHostName > ''", _
    "WQL", &h10 + &h20)
For Each objItem In colItems
    strDomain="DC=" & Replace(objItem.DNSDomain,".",",DC=")
Next
WScript.Echo "Domain: " & strDomain

'Get MP properties from Active Directory
'—————————————
Set objLDAP = GetObject("LDAP://CN=SMS-MP-" & strSiteCode & "-" & _
    strServerName & ",CN=System Management,CN=System," & strDomain)
strInstallString = objLDAP.Get("mSSMSCapabilities")
'Strip everything before the command line
strInstallString = Right(strInstallString, _
    Len(strInstallString) – InStr(strInstallString, "<CommandLine>")-12)
'Strip everything after the command line
strInstallString = Left(strInstallString, _
    InStr(strInstallString,”</CommandLine>”)-1)

WScript.Echo "Install String: \" & strServerName & "\SMS_" & strSiteCode & _
    "\Client\ccmsetup.exe " & strInstallString
 

Share This Post

Leave a Reply