New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
The remote session with the name WinPSCompatSession is not available #11903
Comments
I can not duplicate this. First - I do not have a module name 'modulename' You only get the remoting session if you are loading via compatibility not by default. that is, only the modules in System 32 are remoted. I have tested this extensively and can not, in general, duplicate this. |
"ModuleName" was simply an example, not a real name obviously. I got the error with every module I tried, so I omitted the real names. For example modules AzureAD and ExchangeOnlineManagement which are available in the PSGallery do not work in PS7. And as such I attempted to use the UseWindowsPowerShell switch to load them in PS5.1 remote session. But instead I get the described error, which is not really helpful. I did not know the switch is limited to modules located in system32. If this is intended behavior, then the error message should be clarified to say so. |
You can import the modules fine in PS7, but neither Connect-AzureAD nor Connect-ExchangeOnline cmdlets work. They produce error "Could not load type System.Security.Cryptography.SHA256Cng' from assembly 'System.Core". Which is the reason I wanted to use the UseWindowsPowerShell switch. Neither AzureAD or ExchangeOnline modules are cross-platform. Their cmdlets use .NET Framework namespaces. A known issue, but no timeline for fix. |
I see what you mean! I was using the AZ..accounts module (which does work) with the AzureAD commands - my bad. I can duplicate what you see. This appears to be an issue with the module. The module is marked only with Desktop as the supported edition. To resolve this is a challenge for the Azure team. The Connect=EXOService has the same issue and the module is not marke as Core compatible. @iSazonov - should both these modules get added to the deny list? |
I think it could be a temporary solution. |
I really think it is the best solution for RTM. I strongly feel the product can not go out if there are unexpected surprises like this (and these are two module sets I had not yet tested). It basically tells the user: this is not going to work (today) in PowerShell 7. I think this is a better solution then failing with an error message that is NOT in any way actionable. I get why the error we are seeing here is generated, but the new user is not given any clues as to how to fix this issue. At least with putting these modules in the deny list, you shift the problem to where the solutions lies, ie at the MSOnline and AzureAD product teams. I like the idea of PowerShell team having my back and not letting me load modules that just are not going to work. Today. And bacause that block list is in text - if a working module IS produced, i |
Please also note that there are two Exchange Online modules; Microsoft.Exchange.Management.ExoPowershellModule and ExchangeOnlineManagement. Former is installed from https://portal.office.com and the latter from https://www.powershellgallery.com. There is also predecessor of the AzureAD module, called MSOnline. Which is still very widely in use. |
/cc @anmenaga for information. |
The @doctordns do you also see
Some other hopefully clarifying thoughts:
|
@anmenaga I made a fresh Windows 10 virtual machine to test and installed PS7.0 RC3 on it. I tried importing the PKI module with the UseWindowsPowerShell switch, which worked as expected. Then I tried importing the AzureAD module, which also worked. Unfortunately Connect-AzureAD produces following errors.
If I use Enter-PSSession to enter the WinPSCompatSession and run Connect-AzureAD in there, I get more verbose errors.
Then I attempted to import the ExchangeOnlineManagement module with the UseWindowsPowerShell switch and run Connect-ExchangeOnline and Get-EXOMailbox, all worked fine. Very nice. Next Monday I will test what happens on PS7.0 RC2 as well as RC3 on my work laptop, which is where I originally experienced the "The remote session with the name WinPSCompatSession is not available" error. So I'll get back to you in a few days. |
Right, so. I tested again on my work laptop and... now the UseWindowsPowerShell switch works as expected. And I haven't even rebooted the laptop since, only opened a fresh PS7.0 RC2 session. Which I did multiple times last week as well, without results changing any. Unlike on the virtual machine earlier, both AzureAD and ExchangeOnlineManagement modules do work. I did not get "The handle is invalid" error. I honestly don't know why the UseWindowsPowerShell switch produced the reported error last week, but now it does not. Perhaps there might be relation to VSCode and the PS extension, as I tend to only use VSCode. But I did do test VSCode too and could not replicate the error. All things considered, seems to generally work as expected, with a few mysterious bugs. If you have any ideas how I might help to investigate the original issues as well as the invalid handle issue further, please let me know. |
I can confirm this on > Import-Module PKI
Get-PSSession: The remote session with the name WinPSCompatSession is not available. however, this seems to work: > Import-Module PKI -UseWindowsPowerShell
WARNING: Module PKI is loaded in Windows PowerShell using WinPSCompatSession remoting session; please note that all input and output of commands from this module will be deserialized objects. If you want to load this module into PowerShell Core please use 'Import-Module -SkipEditionCheck' syntax. and this works too: > Import-Module PKI -SkipEditionCheck; |
SO far as I can tell, the PKI module is core compatible PS Cert:\CurrentUser\My\> gmo pki | ft name, CompatiblePSEditions
Name CompatiblePSEditions
---- --------------------
pki {Desktop, Core} So after importing the module, there should be no compatibility remoting serssion as the cmdlets are native. |
@MovGP0, @lehtoj do you know if your environment uses some sort of error redirection mechanism (e.g. redirect error stream to the regular output stream) ? |
I have this problem with Import-Module on PowerShell 7.0 RTM (Get-PSSession: The remote session with the name WinPSCompatSession is not available), with these built-in Windows 10 modules:
|
@anmenaga Nope, no such redirection is taking place. |
In my testing (using Server 1809):
3.DNS CLient works natively. This module also declares itself as Desktop AND Core. |
I manage a few hundred servers and OSs not just Server 2019 so your observations aren’t valid for my environment. Furthermore the stuff I listed is accurate and the reason -UseWindowsPowerShell is broken is because of a bug that exhibits when $ErrorActionPreference = ‘Stop’. Later I found there’s an open issue and a merge request in for it from someone else. |
This may be a compatibility issue - can you post the version numbers of the modules that are not working and which OS you tested under? And what specific issues. For reference - I tested (client and server-side) on Windows Server 2019 1809. running from PowerShell 7.0.0.0 Here are the module versions I saw FailoverClusters - Module Version 3.1.90.0 which is marked as Desktop (aka Windows PowerShell) only but loads/works in compatibility mode. I tested using both Import-Module and module autoload - both create the remoting session and import the module from that session successfully. I was able to test, the module's commands via building and managing a 2-node failover cluster using iSCSI CSV, and to build a SOFS on the cluster. What, specifically, is meant by modules does 'not load'? Can you check to see if your version of this module is moarked accordingly as core compatible? ScheduledTasks - Module version 1.0.0.0 and marked as compatible with Core. Some basic testing works as expected but have not delved deeply. Are you meaning ScheduledTasks or PSScheduledTasks? The latter does not work. The Scheduled Tasks module is marked as core compatible so loads natively - there is no reason to use the -UseWIndowsPowerShell switch to load the module. DNSClient - version 1.0.0.0 and marked as compatible with Core. Built a 2 domain forest, created a second forest, with X-forest trusts, and carried out a wealth of other operations all of which required DNS. Created multiple zones (forward and ptr), RRs etc. I see no issues at all in the Client (or Server0 modules. As this module is marked as core compatible - no need to use the -UseWIndowsPowerShell script. Can you check to see if your version of this module is marked accordingly as core compatible? Finally - you mention Import-WinModule. That command is no longer needed. Import-Module has, in effect, incorporated the functionality of Import-WInModule (and even stops known to not work at all in PowerShell 7 modules). |
No need to go into it further. For others, the fix is on #11980 (disclaimer: I haven’t tested the fix). Until then use Import-WinModule as it doesn’t have this bug. It’s still needed until this is resolved. |
🎉This issue was addressed in #11980, which has now been successfully released as Handy links: |
🎉This issue was addressed in #11980, which has now been successfully released as Handy links: |
Steps to reproduce
Expected behavior
Actual behavior
Environment data
The text was updated successfully, but these errors were encountered: