After updating Windows 10 you may be unable to connect to a remote PowerShell session. This is an issue for versions of Exchange 2010 onwards as we use remote PowerShell for administration. The same applies for Exchange Online in Office 365. Note that directly loading the Exchange PSSnapin is not supported apart from a limited number of documented scenarios, for example this is one of them. For more details on how Exchange uses PowerShell please read this series of posts.
Let’s look at a quick example of what you may see on a Windows 10 machine when trying to connect to Exchange Online.
Update 26-8-2016: See also PowerShell DSC and implicit remoting broken in KB3176934
Update 2-9-2016: An update to correct the issue has been released. Please refer to the note in the CU. To fix this issue, download update 3176938 from the Microsoft Update Catalog website.
Windows 10 Anniversary Edition Repro
Windows PowerShell was launched from its regular shortcut. In the below example I’m using the simple connection script to connect to Exchange Online. It will prompt for credentials and then connect.
All good so far. After entering the credentials we get the regular warning about the redirection, this is expected so don’t panic!
WARNING: Your connection has been redirected to the following URI:
However the red text is never a good thing. Trying to import the PSSession has failed. Bummer.
For the search engines, the detailed error is:
Import-PSSession : Could not load type ‘System.Management.Automation.SecuritySupport’ from assembly
‘System.Management.Automation, Version=188.8.131.52, Culture=neutral, PublicKeyToken=31bf3856ad364e35’.
At C:\Scripts\Connect-EXO.PS1:6 char:18
+ $ImportResults = Import-PSSession $Session
+ CategoryInfo : NotSpecified: (:) [Import-PSSession], TypeLoadException
+ FullyQualifiedErrorId : System.TypeLoadException,Microsoft.PowerShell.Commands.ImportPSSessionCommand
Did the connection really fail? Let’s see where it got to. Trying to use Get-Mailbox fails, so that cmdlet is not available to us.
What about the script module, was that downloaded and created? We will check using Get-Module.
Nope there is no script module which is used to contain the Exchange cmdlets.
For comparison, the below is from a Windows Server 2012 R2 server. Note the script module which is underlined:
That is where the Exchange cmdlets are represented as client side functions. No script module, no function and therefore no cmdlets are available.
Windows 10 PowerShell Details
If we look at the version of PowerShell which is loaded when the Windows PowerShell start menu shortcut is used, we can see that it is a new and updated version of PowerShell. The PSVersion is reported as 5.1.14393.82.
While the issue is worked upon by the teams involved, there is a quick workaround.
Rather than using the default instance of PowerShell, we can go old skool and use a downlevel version. The easiest way is to use the run box to start PowerShell up as version 2.0. You can click Start, then Run and enter the command. Alternatively I love to use the Windows Key + R as a keyboard shortcut to get to the Run box.
In the Run box enter:
PowerShell.exe -Version 2.0
Then we connect in the normal way. In the below example, note that I am showing the OS version and the PowerShell version to prove there is no funny business.