Microsoft

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: [powershell] Import-Module ActiveDirectory . ‘C:\Program Files\Microsoft\Exchange Server\V14\bin\RemoteExchange.ps1’; Connect-ExchangeServer -auto Get-Mailbox -ResultSize Unlimited [/powershell]

This did not cause an exception: [powershell] . ‘C:\Program Files\Microsoft\Exchange Server\V14\bin\RemoteExchange.ps1’; Connect-ExchangeServer -auto Get-Mailbox -ResultSize Unlimited Import-Module ActiveDirectory [/powershell]

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