Exchange Powershell - How to invoke Exchange 2010 module from inside script?

thepip3r picture thepip3r · May 17, 2011 · Viewed 211.2k times · Source

I'm writing a script that does a number of things with AD and Exchange and just got to the part of the GUI where I need to start working with Exchange but don't see where I can manually specify to include the Exchange module. The normal process I'm familiar with is import-module activedirectory but import-module exchange doesn't work.

I performed a Get-Module -ListAvailable | Select Name, and don't see anything indicating Exchange. However, the Exchange Management Shell IS loaded on the Exchange server I'm working on.

Does anyone know how to include the Exchange 2010 module in my script so I can use the exchange-specific cmdlets internally? TIA...

Answer

mjolinor picture mjolinor · May 17, 2011

You can do this:

add-pssnapin Microsoft.Exchange.Management.PowerShell.E2010

and most of it will work (although MS support will tell you that doing this is not supported because it bypasses RBAC).

I've seen issues with some cmdlets (specifically enable/disable UMmailbox) not working with just the snapin loaded.

In Exchange 2010, they basically don't support using Powershell outside of the the implicit remoting environment of an actual EMS shell.