Powershell 5.1 snap in registration errors

12.3k views Asked by At

To preface this, this script i made that involves creating 2007 MS Exchange mailboxes had worked a week or two ago, and suddenly gave me an error (below) from this:

Add-PSSnapin Microsoft.Exchange.Management.PowerShell.Admin

error given:

Add-PSSnapin : No snap-ins have been registered for Windows PowerShell version 5.

I have been all over and can't find anything to help. the command get-PsSnapins -registered doesn't give me anything. I did a clean windows 7 install, did all the windows updates, everything i can think of. I've tried running it without that snap-in but powershell doesn't recognize it as a cmdlet. All out of ideas and options

I am an admin on the network, machine, and running powershell as an admin. Execution policy is set to unrestricted

2

There are 2 answers

5
HAL9256 On

As an FYI, PowerShell 5.0+ is incompatible with Microsoft Exchange 2013: Product Compatibility Status

You should use PSRemoting to connect to the Exchange server, and run from there Directly Loading Exchange 2010 or 2013 SnapIn Is Not Supported:

$ExSession =  New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri 'http://exServer01.contoso.com/PowerShell/' -Authentication Kerberos
Import-PSSession ($ExSession) -AllowClobber

If this was working for you in the past, make sure that you are launching the 32 bit Windows PowerShell (x86) version of PowerShell, as the Exchange Snapin is not 64 bit.

0
hdoghmen On

Try

Get-Module -Name Microsoft.Exchange.Management.PowerShell.Admin -ListAvailable | Import-Module