The script gets the Conferencing Policy assigned to a user in Lync and saves it to a property of the user account. This can be used to quickly view which policies are assigned to which users.
To automatically update user accounts with Conferencing Policies assigned to them, you can create a scheduled task that runs the script on a regular basis. To run a script as a part of a scheduled task, use the Run a program or PowerShell script action.
Parameters:
- $lyncServer - Specifies the fully qualified domain name (FQDN) of your Lync Server.
- $propertyName - Specifies the LDAP display name of the property that will be used to store the Conferencing Policy name.
Note: To be able to assign a policy, the user account that is used to run the script must be assigned to the CsUserAdministrator role or the CsAdministrator role in Lync.
PowerShell
$lyncServer = "lyncserver.domain.com" # TODO: modify me
$propertyName = "adm-CustomAttributeText1" # TODO: modify me
try
{
# Connect to the Lync Server
$sessionOptions = New-PSSessionOption -SkipRevocationCheck -SkipCACheck -SkipCNCheck
$session = New-PSSession -ConnectionUri https://$lyncServer/ocspowershell `
-SessionOption $sessionOptions -Authentication NegotiateWithImplicitCredential
Import-PSSession -session $session
# Get the Conferencing Policy
$conferencingPolicy = (Get-CsUser -Identity "%userPrincipalName%").ConferencingPolicy
# Update the attribute
$Context.TargetObject.Put($propertyName, $conferencingPolicy)
$Context.TargetObject.SetInfo()
}
finally
{
# Close the remote session and release resources
Remove-PSSession -Session $session
}