How many kilograms is your voicemailbox? Even if you knew, how would you change it? That’s not what this article is about. How would we take a massive number of people’s mailboxes and make changes to them? That’s the ticket, and we’re referring to Exchange Server 2010 hosted mailboxes with Unified Messaging. Yes, some of this article might even apply to Exchange Server 2007, but it’s focused on 2010.
Let’s say that the human resources department (or some of the other powers that be) have a spreadsheet or database of change requests for you. They want you to create some voicemail boxes for some people, delete others, reset some PINs, and in some cases create or delete a basic mailbox as well. Instead of tackling that whole solution in one article, we will start with one part of it – how would we enable voicemail for people with existing Exchange 2010 mailboxes?
If the words Exchange Management Shell (EMS) aren’t already ringing in your ears, perhaps you need to get up to speed on automation with Exchange 2010, Exchange 2007, and Windows PowerShell. Specifically, we’ll tackle this problem with at least two cmdlets. The first, Import-CSV, doesn’t exactly extract information from the spreadsheet or database directly (although that’s a far more interesting endeavor which PowerShell could tackle), but simply takes a comma separated values (CSV) file which could be exported out of Excel or other software. With a CSV file representing the change requests, PowerShell’s Import-CSV cmdlet can bring the data into quick grasp. Another cmdlet we’ll use is Enable-UMMailbox, which isn’t is basic PowerShell 2.0, but in the extensions which Exchange 2010′s EMS provides. This facilitates making the actual changes.
First, let’s look at an example change request file (changevm.csv):
request,first,last,ummailboxpolicy,pin
newvm,Samantha,Spade,”Outbound Sales”,135790
newvm,Wanda,Wombat,”Outbound Sales”,444333
resetpin,Alex,Maravilla,”Marketing”,111111
newvm,Susan,Murphy,”Engineering”,864321
Each Unified Messaging Mailbox Policy includes a dial plan and other options. Consider the following pipeline.
import-csv changevm.csv | %{ $who = $_; switch( $_.request ){
newvm { Enable-UMMailbox -Identity $(Get-Mailbox “$($who.first) $($who.last)”) `
-UMMailboxPolicy $who.ummailboxpolicy -Pin “$($who.pin)” -PinExpired $false }
resetpin { Set-UMMailboxPin -Identity $(Get-Mailbox “$($who.first) $($who.last)”) `
-Pin “$($who.pin)” -PinExpired $true }
default { “Cannot handle {0} request for {1}” -f $_,”$($who.first) $($who.last)” }
} }
This looks at the keyword at the beginning of each line (the change “request” type), and supports both “newvm” (new voice mailbox) requests, and a “resetpin” requests, but also includes a default selector in the switch statement to alert you that this little code block doesn’t know how to handle other kinds of requests (but could easily be enhanced).
Note that the value of each person’s change request ($_) is saved in the $who variable just inside the ForEach-Object (%) loop because the switch construct also assigns the special variable $_, but with the value of its expression (inner pipeline) which is $_.request.
Exchange 2010′s Enable-UMMailbox cmdlet is used to create a unified messaging mailbox for voicemail and inbound faxes for a user with an existing mailbox. Their PIN is set to the value from the request file, and the PinExpired property is set to false so that the user doesn’t have to change it. This is a calculated security risk.
For the PIN reset scenario, the Set-UMMailboxPin cmdlet is used, and in this case we chose to set the PinExpired value to true so that the user must change their PIN when they next connect to their voice mailbox.
The sky’s the limit with automation and Exchange Server 2010. How often do you have to handle similar requests? The shell can help.
-Brad
Related Courses
Configuring, Managing, and Troubleshooting Microsoft Exchange Server 2010 (M10135)

