
OK so, I have just been approached by a client to assist with bulk AD attribute updates to address a particular issue with Jabber Outlook presence not functioning correctly.
I don’t ever really keep my scripts and tend to forget about them, but then I realised that I had a blog I set up a while back!!!! So I decided to post this one out for all to use and adapt as necessary!!!
Basically the client is running a Cisco Call Manager telephony system that was deemed too cumbersome to signin to their phones with the samAccountName attribute (the default utilised by CCM), and decided to utilise another AD attribute ‘EmployeeID’
I had previously written a script to update this attribute for my client so we knew this was all populated.
However, with this being the case this essentially broke the Jabber integration with Outlook clients. (As discussed in this article) – https://supportforums.cisco.com/thread/2163183
In short, the answer was that due to the fact users were signing in with their EmployeeID, Outook requires a ProxyAddresses entry to match the domain and employeeid in the format: sip:<employeeid>@<domain.com>
After a quick bit of scripting I made myself a little Powershell script that will do the following:
- Accept a SIP domain user input
- Search AD for all Accounts without a NULL EmployeeID Attribute
- Remove the accounts that already have a proxyAddress matching sip:<employeeID>@<domain.com>
- Export the List to a CSV File
- Prompt the User if they would like to update the accounts
This script is at v.1_0 and is as follows:
#################################################################
# WRITTEN BY: John Lunn – john@lunn-ltd.co.uk
# DATE: 10.04.14
# REV: 1.0
# Twitter: @jonnychipsz
#
# This script will prompt for a valid SIP domain to be entered
# and search AD for all accounts with an employeeID attribute set
# it will then prompt the user if they would like to add an entry to the ProxyAddresses AD
Attribute in the format
# sip:<employeeID>@domain.com
#
Write-host “”
write-host “WARNING: THIS SCRIPT WILL MODIFY AD PROPERTIES, PLEASE ENSURE YOU ARE FULLY AWARE OF
WHAT THIS SCRIPT IS BEING UTILISED FOR BEFORE RUNNING!!!” -foregroundcolor “Red”
write-host “”
write-host “Attributes Modified: ProxyAddresses” -foregroundcolor “Yellow”
write-host “”
Write-Host “This script was written by John Lunn (john.2.lunn@bt.com)” -foregroundcolor “yellow”
Write-Host “For the purposes of adding an entry to the ProxyAddresses attribute in Active
Directory in the following format:” -foregroundcolor “yellow”
Write-Host “sip:<employeeID>@domain.com” -foregroundcolor “yellow”
Write-Host “”
$sipdomain = Read-Host “Please enter your sip domain name in the format ‘domain.com'”
$users = get-aduser -ldapfilter “(employeeid=*)” -Properties name,proxyaddresses,employeeid
$validusers = @()
foreach ($user in $users){
$empid = $user.employeeid
if ($user.proxyaddresses -notcontains “sip:$empid@$sipdomain”)
{
$validusers += $user
}
}
$validusers | ft name,employeeid,proxyaddresses
$validusers | Export-CSV “C:\SIP Address Update – Accounts To Be Updated.csv”
write-host $validusers.count “AD Account(s) found with a valid employeeid and no matching SIP
ProxyAddress” -foregroundcolor “Green”
write-host “”
write-host “A CSV eport has been generated: C:\SIP Address Update – Accounts To Be Updated.csv” –
foregroundcolor “yellow”
$title = “Update All Accounts Now?”
$message = “Would You Like to update these AD Accounts with the additional SIP Address? i.e.
sip:<employeeid>@”+$sipdomain
$yes = New-Object System.Management.Automation.Host.ChoiceDescription “&Yes”,”Updates All
Accounts.”
$no = New-Object System.Management.Automation.Host.ChoiceDescription “&No”,”Cancels the request.”
$options = [System.Management.Automation.Host.ChoiceDescription[]]($yes, $no)
$result = $host.ui.PromptForChoice($title, $message, $options, 0)
if ($result -eq 0){
foreach ($validuser in $validusers) {Set-ADUser $validuser.distinguishedname -Add @
{proxyaddresses=”sip:”+$validuser.employeeid+”@”+$sipdomain}}
write-host “”
write-host $validusers.count “records updated – Thank You for using this script!” –
foregroundcolor “Green”
write-host “”
}
else{
write-host “”
write-host “Action Aborted – No Accounts updated :-)” -foregroundcolor “red”
write-host “”
}
$users.clear()
$validusers.clear()
#################################################################
Feel Free to use, but drop me a line if you do!!! – I take no responsibility for any issues arising from the outcome of running this script! – Unless I run it of course 🙂