Today I’ve been looking into how I can create and Exchange Mailbox using PowerShell.
A little background. We have been using PowerShell to create new Active Directory accounts for awhile, but hadn’t looked into being able to create the mailbox on Exchange at the same time. The biggest problem (more a concern) is that I thought we needed to install the Exchange Management Tools (EMC and EMS) on our domain controllers or admin desktops. I was concerned these servers and computers wouldn’t get updated at the same time as our Exchange Servers and I didn’t want services packs and other updates to get out of sync.
I was doing some searching today and came across a site that talks about configuring a PowerShell profile that would load certain modules when you start PowerShell (Implicit Remoting).
To do this you first start PowerShell and type the following: New-Item -Itemtype file -path $profile -force
Next you type: notepad $profile
Now you can add the following lines to the file. The first line below imports the AD cmdlets and the second and third lines import the Exchange cmdlets.
import-module ActiveDirectory
$ExchangeTools = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri http://labex01.iga.local/PowerShell/ -Authentication Kerberos
Import-PSSession $ExchangeTools
Now whenever you start PowerShell the above commands will be executed.
One other note. I have been using the PowerShell ISE for a lot of my testing and found that you need to create a profile for that as well. The normal PowerShell profile and the PowerShell ISE profile files are different.
Source: Mike Pfeiffer’s Blog
Be First to Comment