Enable all users in an OU for Lync 2010 with Powershell

If you want to enable all users in a OU for lync use this powershell command:

get-csADuser -OU "OU=Office,OU=Head,dc=dcserver,dc=local" | Enable-CsUser -RegistrarPool YOUR-LYNC-POOLSERVER -SipAddressType emailaddress
VN:F [1.9.22_1171]
Rating: 0.0/6 (0 votes cast)

Lync 2010 Assign Client Policies By Active Directory Groups

After we got our new Lync 2010 setup done, we was missing one key feature.
We want to assign Client policies by Active Directory groups instead of the need to login to Lync admin and change it.

So we made a simple powershell script to do the work for us

save it as Lync-SetClientPolicy.ps1

Import-Module "C:\Program Files\Common Files\Microsoft Lync Server 2010\Modules\Lync\Lync.psd1"
$ADGroupName = $args[0]
$ClientPolicy = $args[1]

$strFilter = "(&(objectCategory=Group)(SamAccountName=" + $ADGroupName +"))"
$objDomain = New-Object System.DirectoryServices.DirectoryEntry

$objSearcher = New-Object System.DirectoryServices.DirectorySearcher

$objSearcher.SearchRoot = $objDomain

$objSearcher.Filter = $strFilter

$objSearcher.SearchScope = "Subtree"

$colProplist = "member"

foreach ($i in $colPropList)

{[void] $objSearcher.PropertiesToLoad.Add($i)}

$colResults = $objSearcher.FindAll()

foreach ($objResult in $colResults)
{
$objItem = $objResult.Properties;
$group = $objItem.member
}

foreach ($user in $group)

{
$userlync= Get-CsUser -Identity $user
if ($userlync.ClientPolicy -like $ClientPolicy)
{

}
else
{
Grant-CsClientPolicy $user -PolicyName $ClientPolicy
}

}

And then a bat file to execute it from “scheduled task”

powershell -command "& 'C:\script\Lync-SetClientPolicy.ps1' "Lync-ClientPolicy-Sales" "Sales" "
powershell -command "& 'C:\script\Lync-SetClientPolicy.ps1' "Lync-ClientPolicy-Default" "Default" "
VN:F [1.9.22_1171]
Rating: 0.0/6 (0 votes cast)