Change Users' Exchange UM Dial Plan

Author by Michael Epping

I ran into an issue recently where Lync users couldn't call an Exchange auto-attendant, so I dug into the Exchange UM server's Application log and discovered this: 2013-04-26 10_53_08 Note the section "MainNumber.Lync Server 2010 UM Dial Plan".  The problem here is that the UM Dial Plan, Lync Server 2010 UM Dial Plan, has spaces in it.  Exchange servers can display all sorts of weird behavior when you include spaces in the names of UM Dial Plans, hunt groups, etc.  The fix should be as simple as just changing the dial plan's name in the Exchange Management Console, right?  Unfortunately that isn't the case; a dial plan's name can't be changed once the dial plan has been created, so we need to create a new dial plan with identical settings, but with a name with no spaces.  Then we need to disable every users' UM mailbox and then re-enable them with the new UM dial plan. I went ahead and created a new UM dial plan with the same settings as my old dial plan.  Note how the name is both simple and lacks any spaces: 2013-04-26 10_58_47 If you have just a handful of UM enabled users you could use the Exchange Management Console to disable each of them and then re-enable each by hand.  However, in my environment I have 91 UM enabled mailboxes, so that would be a little tedious.  Instead, I'll use PowerShell to make my job a little easier.
      • First, open the Exchange Management Shell and run this command: Get-UMMailbox | Select-Object PrimarySmtpAddress,SIPResourceIdentifier,@{Name='Extensions';Expression={[string]::join(";", ($_.extensions))}} | Sort-Object PrimarySmtpAddress | Export-Csv UMUsers.csv -NoTypeInformation
      • The complicated bit of the command around the Extensions property is because Extensions is a multi-valued property and won't export to CSV correctly if we just used "Select-Object PrimarySmtpAddress,SipResourceIdentifier,Extensions".
      • Copy the UMUsers.csv file to a computer with Excel installed and open it in Excel.
      • You should have 3 columns, PrimarySmtpAddress, SIPResourceIdentifier, and Extensions.  The Extensions column may have multiple values for each user.  For example, you can see below that my users have 4 digit extensions and their SIP addresses displayed there:
2013-04-26 11_30_17
  • We only need the 4 digit extensions in the 3rd column, so we need to remove the SIP addresses from column C.  Select the entire column C, go to the Data tab in the ribbon and select Text to Columns:
  2013-04-26 12_03_05
  • Make sure Delimited is selected and click Next.  Then select Semicolon as your delimiter and click Next.
2013-04-26 13_15_32
  • Click Finish and you should now have two Extensions columns instead of one.  One column should have the SIP addresses and the other the 4 digit extensions.  Delete the entire column with the SIP addresses so that your C column is now just the 4 digit extensions.
  • If you had any 4 digit extensions that begin with zeros you may notice that Excel automatically removed the zeros.  For example my 0001 extension was shortened to just 1.  To fix this, modify the cell so that the data in it is actually '0001 with a single quote before the 0001.  That will prevent Excel from changing the data.
  • Next, highlight cell D2, which should be empty.  Enter this text, modified to suit the name of your UM Mailbox Policy, in D2 and hit enter: =CONCATENATE("Enable-UMMailbox -Identity ",A2," -UMMailboxPolicy Lync -SipResourceIdentifier ",B2," -Extensions ",C2,"")
  • The parameter after -UMMailboxPolicy should be the name of your new UM Mailbox Policy that doesn't have any spaces in it.
  • Your results should look something like this:
2013-04-26 13_40_37
  • Highlight cell D2 and then grab the square in the lower right corner of the cell.  Drag it down to recreate the command you just typed in for each user in your list.  When done you should have a whole list of commands, one for each user.
2013-04-26 13_45_34
  • Highlight all of column D and copy it.  Next, open up PowerShell ISE, PowerGUI, Notepad, or whatever your PowerShell script editor of choice is and paste in the contents of the Excel spreadsheet you just copied:
2013-04-26 14_30_40
  • Notice that line 1 doesn't have any relevant information in it.  In line 1 put this: Get-UMMailbox | Disable-UMMailbox
  • In my script I also added a new line 2 that causes the script to sleep for two minutes after running line 1.  This may not have been necessary, but I wanted to be very sure that the first line finished its job before the rest of the script ran.  Therefore, my line 2 reads like this: Start-Sleep -Seconds 120
  • Save your script as a .ps1 file.  I named mine Redo-UMMailboxes.ps1.  Then copy it back to your Exchange server.  Open Exchange Management Shell and follow these steps:
  • Navigate to the location of the file.  On my server I ran this: cd C:Downloads
  • Run the script: .Redo-UMMailboxes.ps1
When the script is done running all of your UM users have been disabled and then re-enabled with the same extensions and SIP addresses.  However, their PINs have been changed, but each user will receive an email notification including their newly reset PIN.
Author

Michael Epping

Systems Engineer