Get-Mailbox crashes PowerShell

I was working on a PowerShell script for some mundane management task in Exchange 2010 SP3, and was met with a crash in the Integrated Scripting Environment when trying to run the script:
powershell_error

After some trial and error, I gave up and resorted to a Google search, and found the answer in some forum post on technet.

Turns out there is some bug that appears if you load the Active Directory module, before connecting to the Exchange-server.

This caused an exception:

Import-Module ActiveDirectory
. 'C:\Program Files\Microsoft\Exchange Server\V14\bin\RemoteExchange.ps1'; Connect-ExchangeServer -auto
Get-Mailbox -ResultSize Unlimited

This did not cause an exception:

. 'C:\Program Files\Microsoft\Exchange Server\V14\bin\RemoteExchange.ps1'; Connect-ExchangeServer -auto
Get-Mailbox -ResultSize Unlimited
Import-Module ActiveDirectory

Environment: PowerShell 3.0, Windows Server 2008 R2, Exchange 2010 SP3.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.