Reminder – Adding Exchange 2010 or 2013 snap-in using Add-PSSnapin not supported – Better use Remote Powershell (From RMilne)
As a bookmark, my buddy Rhoderick Milne has written an excellent article about the best way to invoke Exchange PowerShell environment (other than loading the “Exchange Management Shell” itself from the Windows menus – for example, if you want to use a Windows Powershell session you’re currently in, or simply the Powershell Integrated Scripting Environment (ISE)) is to use Remote Powershell.
The use of “Add-PSsnapin Microsoft.Exchange.Management.PowerShell.E2010 ” is not supported.
The following instead, using Remote PowerShell, is supported:
$Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri http://<ServerFQDN>/PowerShell/ -Authentication Kerberos
… and to disconnect the session:
- either close your powershell window
- or to stay in your current session, use Remove-PSSession $Session
Note1: the above example is using http (port 80, not encrypted), but the session being secured as we used the –Authentication Kerberos method.
For a remote forest connection, you must use HTTPS, and for that, you need to enable “Windows Authentication” on your Poweshell vdirs (on E2013, do this for both “Default Web SitePowershell” and “Exchange Back EndPowerShell” vdirs)
$Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri https://<ServerFQDN>/PowerShell/ –Credentials (Get-Credentials)
For a lab environment for which you don’t have trusted certs, you may have certificate check errors, you can specify to ignore the cert checks using the PSSessionOptions:
$PSOptions = New-PSSessionOption –SkipCACheck –SkipRevocationCheck -SkipCNCheck
then same as above but adding the –SessionOptions parameter:
$Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri https://<ServerFQDN>/PowerShell/ –Credentials (Get-Credentials) –SessionOption $PSOptions
All detailed information are on Rhoderick’s blog post about Directly Loading Exchange 2010 or 2013 SnapIn Is Not Supported, this post is a bookmark and a refresher.