Skip to Content

PowerShell-OCS2007r2 Communicator account update

We migrated from LCS2005sp1 to OCS2007r2 a while ago but for various reasons continued to use the Communciator 2005 client. With the Windows 7 migration we are changing to Communicator 2007r2 clients. On new accounts, there is nothing to do administratively, but on the older migrated accounts (of which the majority are) we need to manually check the 'Enable Enhanced Presence' box on each account. The numbers involved make this unappealing even in batches of 20-40 a day.

Have I mentioned how much I like PowerShell?

For this to work you will need the Quest AD Cmdlets, and OCS2007r2 administration tools installed on your system. I have two scripts, one that's really for the help desk to use to check an account more quickly and the other to use to enable bulk accounts. There is very basic help and example texts, still new to using that part of a script. I put these in a functions.ps1 library and load with my profile

This first one merely gets some information for you given the user logon id.

# check-Communicator
function check-Communicator
{
<#
.SYNOPSIS
 
Check if user is enabled for Communicator and gets the SIP address for them.
Requires Quest AD Cmdlets and OCS2007r2 Admin tools installed.
 
.EXAMPLE
 
check-Communicator ca99999
 
#>
 
  # Mandatory Input parameters, throw an error if null or blank
  Param ( 
    [parameter(Mandatory = $true, ValueFromPipeline=$true)] 
    [ValidateNotNullOrEmpty()] 
    [String]
    $UserName
  )
 
  # get user status and display on cmdline
  $user = get-qaduser $username  -DontUseDefaultIncludedProperties -IncludedProperties 'msRTCSIP-UserEnabled','msRTCSIP-PrimaryUserAddress' 
  $sip = $user.'msRTCSIP-PrimaryUserAddress'
 
  # Get OCS User Enhanced Presence status (Communicator 2007r2)
  $OCSUser = Get-WmiObject -Query "Select * from MSFT_SIPESUserSetting where PrimaryURI = '$sip'"
 
  Write-Host " "
  Write-Host "User Name: " $user.DisplayName 
  Write-Host "Communicator logon" $sip
  Write-Host " "
  Write-Host "Enabled for Communciator: " $user.'msRTCSIP-UserEnabled'
  Write-Host "Enabled for Communciator 2007r2: " $OCSUser.EnabledForEnhancedPresence
  Write-Host " "
 
} 

This one will enable the EnhancedPresence flag for the user given the user logon id.

# enable-OCSuserEnhancedPresence 
function enable-OCSUserEnhancedPresence 
 
 
{
<#
.SYNOPSIS
 
Get OCS enabled and SIP address for user.  Requires Quest AD Cmdlets and
OCS2007r2 admin tools installed.
 
.EXAMPLE
 
enable-OCSuserEnhancedPresence jdoe
 
.EXAMPLE
 
$users = get-content ./users.txt
foreach($user in $users) { enable-OCSuserEnhancedPresence $user }
 
#>
 
  # Mandatory Input parameters, throw an error if null or blank
  Param ( 
    [parameter(Mandatory = $true, ValueFromPipeline=$true)] 
    [ValidateNotNullOrEmpty()] 
    [String]
    $UserName
  ) 
 
  # get user status and display on cmdline
  $user = get-qaduser $username  -DontUseDefaultIncludedProperties -IncludedProperties 'msRTCSIP-UserEnabled','msRTCSIP-PrimaryUserAddress' 
  $user | select Name, msRTCSIP-UserEnabled, msRTCSIP-PrimaryUserAddress
 
  # Set SIP address for use in WMI query
  $sip = $user.'msRTCSIP-PrimaryUserAddress'
 
  # Populate OCS User properties
  $OCSUser = Get-WmiObject -Query "Select * from MSFT_SIPESUserSetting where PrimaryURI = '$sip'"
  $OCSUser.EnabledForEnhancedPresence = $true
  $OCSUser.put()
 
} 

Commenting on this Blog entry is closed.