Share via


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 https://<ServerFQDN>/PowerShell/ -Authentication Kerberos

Import-PSSession $Session

 

… 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.

Comments

  • Anonymous
    April 12, 2016
    Hello, great post. :)
  • Anonymous
    June 03, 2016
    How do we open a new Exchange PS session that has customized MaximumReceivedDataSizePerCommandMB & MaximumReceivedObjectSizeMB settings? I can create a PSSessionConfiguration with those settings, but that session doesn't have the Exchange commands available, and I can't modify the Exchange session config Microsoft.Exchange. Right now the only way I can get it to work is to create my customized session, load it, then use Add-PSSnapin Microsoft.Exchange.Management.PowerShell.SnapIn.
    • Anonymous
      June 03, 2016
      never mind, figured it out using New-PSSessionOption:$PSOptions = New-PSSessionOption -MaximumReceivedDataSizePerCommand 1073741824 -MaximumReceivedObjectSize 1073741824 -IdleTimeout 43200000$UserCredential = Get-Credential$Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri http://FQDN/PowerShell/ -Authentication Kerberos -Credential $UserCredential –SessionOption $PSOptionsImport-PSSession $Session