List OCS Pools and Policies Using a VBScript

OCS Script: Here's a simple VBScript that displays all of the Office Communication Server (OCS) policies in your Active Directory. This script is valuable, because you'll need the distinguished name of the policy object if you want to configure a user to use that policy, as I do in my previous post: Enable an OCS User using a VBScript

The script goes to the AD container where the OCS policies are stored, looks at each one, gets the name of the policy, the policy type (meeting, voice, etc), and the distinguishedName for you to use in your other scripts. Notice that the name of the policy is embedded in the policyContent attribute, and the policyContent is an XML string. So, I load that XML into a Microsoft.XMLDOM object and iterate through it to get the name.

'build an XML object for parsing the policy content
Set xmlDoc = CreateObject("Microsoft.XMLDOM")
xmlDoc.async= False
'find the policies container in AD
Set dse = GetObject("LDAP://RootDSE")
configDN = dse.Get("ConfigurationNamingContext")
ocsPolicyContainerDN = "CN=Policies,CN=RTC Service,CN=Services," & configDN
Set ocsPolicyContainer = GetObject("LDAP://" & ocsPolicyContainerDN)
for each ocsPolicy in ocsPolicyContainer
policyType=ocsPolicy.Get("msrtcsip-policyType")
 if policyType = "uc" Then policyType = "Voice Policy"
 if policyType = "meeting" Then policyType = "Meeting Policy"
 policyDN = ocsPolicy.distinguishedName
 policyContent = ocsPolicy.Get("msRTCSIP-PolicyContent")
'parse the policy Name out of the XML formated policy content
 xmlDoc.loadXML(policyContent)
 for each x in xmlDoc.documentElement.childNodes
  Set nodeId = x.attributes.getNamedItem("name")
   if nodeId.Value = "Name" Then
    Wscript.Echo "Name: " & x.text
    Wscript.Echo "Type: " & policyType
    Wscript.Echo "  DN: " & policyDN
    Wscript.Echo ""
   End If
 Next
Next

And, here's a VBScript that lists the OCS pools in your AD. Very simple...

'find the pools container in AD
Set dse = GetObject("LDAP://RootDSE")
configDN = dse.Get("ConfigurationNamingContext")
ocsPoolContainerDN = "CN=Pools,CN=RTC Service,CN=Services," & configDN
Set ocsPoolContainer = GetObject("LDAP://" & ocsPoolContainerDN)
'display info about each pool
for each ocsPool in ocsPoolContainer
 Wscript.Echo "Name: " & ocsPool.cn
 Wscript.Echo "  DN: " & ocsPool.distinguishedName
 Wscript.Echo ""
Next

0 comments:

Post a Comment

Related Posts Plugin for WordPress, Blogger...