List OCS Policies Using PowerShell

How to list OCS Policies with PowerShell.  In a previous article, we showed how to List OCS Pools and Policies with a VBScript.  The idea being that you'll need the distinguished name of the policy that you want to apply to a user with any script that you use to apply a policy.  You can find that and the other OCS related scripts from ITAdminTools here, written in Perl and VBScript.  Well, it's about time we start adding PowerShell examples to the site.

The script gets the path of the configuration context of your Active Directory, finds the policies container, then lists the policies, displays the distinguished name (DN), policy type, and the policy content.

$configurationContainer = ([adsi] "LDAP://RootDSE").Get("ConfigurationNamingContext")
$policyContainer = [adsi] "LDAP://CN=Policies,CN=RTC Service,CN=Services,$configurationContainer"
$policies = $policyContainer.psbase.children
foreach($policy in $policies)
{
 $content=([xml] $policy.Get("msrtcsip-policycontent")).instance.property
 $policyType=$policy.Get("msrtcsip-policyType")
 $dn=$policy.distinguishedName
 "--------------------------------------------------------------------"
 ""
 "DN: $dn"
 "Policy Type: $policyType"
 $content ¦ ft
}

Another OCS scripting example brought to you by ITAdminTools.com!

0 comments:

Post a Comment

Related Posts Plugin for WordPress, Blogger...