Exchange UM Extension Changes

A while ago, i had to come up with a way that would fix all of our EUM extensions for the company I work for with the wrong number of extensions in preparation for Office 365 Online Archiving. They require a 10 digit extension to migrate.

(I didn't find much on the internet so I had to write most of this from scratch.)

The idea is to gather all users from Exchange 2013 environment with 4 digit extensions. Must be ran in Exchange Management Console.

Get-UMMailbox -resultsize unlimited | where {$_.extensions.length -eq 4} |select-object name,samaccountname,UMDialPlan,phonenumber,@{Expression={$_.Extensions};Label="Extensions";} | export-csv c:\source\UMInfo.csv

Then use that list to get their telephone numbers which we will use as their new 10 digit extension.

Import-Csv c:\source\UMInfo.csv | Foreach-Object{Get-ADuser $_.SamAccountName -properties telephonenumber} |select-object samaccountname,telephonenumber | export-csv c:\source\ADPhoneNum.csv

Now that you have the numbers for all the users in UMInfo.csv, Import that into the next script to add the extensions to each of the users. You may need to clean up the phone numbers using find and replace for all the "-"'s and "(###)"'s. Add the telephonenumber column to the csv UMInfo.csv. You'll need this for this next part.

Import-Csv c:\source\UMInfo.csv | 
Foreach-Object{$mbx=Get-Mailbox $_.samaccountname 
$dp=$_.UMDialPlan
$ab = $_.telephonenumber
Write-host $dp
Write-host $ab
$mbx.EmailAddresses +="eum:$ab;phone-context=$dp.DOMAIN.com" 
Write-host $mbx.EmailAddresses
Write-host "eum:$ab;phone-context=$dp.DOMAIN.com"
Set-Mailbox $_.samaccountname -EmailAddresses $mbx.EmailAddresses}

Once all the users have the new extension, I would use this script to clean up those with the extensions to be safe.

Get-UMMailbox -resultsize unlimited | where {$_.extensions.length -eq 4} |select-object name,samaccountname,UMDialPlan,phonenumber,@{Expression={$_.Extensions};Label="Extensions";} | export-csv c:\source\New4DigList.csv

This next part will delete the 4 digit extensions.

Import-Csv c:\source\New4DigList.csv | 
Foreach-Object{$mbx=Get-Mailbox $_.samaccountname 
$dp=$_.UMDialPlan
$ab = $_.PhoneNumber
Write-host $dp
Write-host $ab
$mbx.EmailAddresses -="eum:$ab;phone-context=$dp.DOMAIN.com" 
Write-host $mbx.EmailAddresses
Write-host "eum:$ab;phone-context=$dp.DOMAIN.com"
Set-Mailbox $_.samaccountname -EmailAddresses $mbx.EmailAddresses}

I hope this helps anyone with this issue in their environment and feel free to comment for a better solution or any questions about this process.

Thanks for connecting with me!



Comments

Post a Comment