When connecting to Exchange Online, is starts to import the session commands (but slow), then throws an ERROR_WSMAN_INVALID_SELECTORS. Account used is regular account (non-MFA).
Open Bash on Ubuntu on Windows
Start PowerShell session
$O365Credential = Get-Credential
$Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri https://outlook.office365.com/powershell-liveid/ -Credential $O365Credential -Authentication Basic -AllowRedirection
Import-PSSession -Session $Session
Connection to Office 365 session.
Import-PSSession : Running the Get-Command command in a remote session reported the following error: Starting a command on the remote server failed with the following error message : ERROR_WSMAN_INVALID_SELECTORS: The
WS-Management service cannot process the request because the request contained invalid selectors for the resource. For more information, see the about_Remote_Troubleshooting Help topic..
At line:1 char:1
Bash on Ubuntu on Windows
Distributor ID: Ubuntu
Description: Ubuntu 16.04.2 LTS
Release: 16.04
Codename: xenial
$PSVersionTable:
PSVersion 6.0.0-beta
PSEdition Core
BuildVersion 3.0.0.0
CLRVersion
GitCommitId v6.0.0-beta.1
OS Linux 4.4.0-43-Microsoft #1-Microsoft Wed Dec 31 14:42:53 PST 2014
Platform Unix
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0...}
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
WSManStackVersion 3.0
@michelderooij Thanks for the Issue report!
/cc @PaulHigin Could you please comment the Issue?
I have a very similar problem. I'm not running Import-PSSession, instead I'm using Invoke-Command with -Session. The first time I use Invoke-Command is works fine, but the second time I use Invoke-Command on the same session it fails with ERROR_WSMAN_INVALID_SELECTORS.
My $PSVersionTable is
PSVersion 6.0.0-beta
PSEdition Core
BuildVersion 3.0.0.0
CLRVersion
GitCommitId v6.0.0-beta.2
OS Linux 4.4.0-47-generic #68-Ubuntu SMP Wed Oct 26 19:39:52 UTC 2016
Platform Unix
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0...}
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
WSManStackVersion 3.0
I have the same problem, in my case I'm trying to login to Office365 from native Ubuntu (no Windows involved on the client side).
PS /home/mpw/Downloads> $Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri https://outlook.office365.com/powershell-liveid/ -Credential $UserCredential -Authentication Basic -AllowRedirection
New-PSSession : [outlook.office365.com] Processing data from remote server outlook.office365.com failed with the following error message: ERROR_WSMAN_INVALID_SELECTORS: The WS-Management service cannot process the request because the request contained invalid selectors for the resource. For more information, see the about_Remote_Troubleshooting Help topic.
At line:1 char:12
+ $Session = New-PSSession -ConfigurationName Microsoft.Exchange -Conne ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : OpenError: (System.Manageme....RemoteRunspace:RemoteRunspace) [New-PSSession], PSRemotingTransportException
+ FullyQualifiedErrorId : 1,PSSessionOpenFailed
For those of you having an issue, can you try 6.0 GA release? @dantraMSFT made some fixes to the PSRP client that should have addressed this issue
@SteveL-MSFT I am getting the same error on Powershell 6.0.2
I am using Ubuntu 14.04.3 LTS
Import-PSSession : Running the Get-Command command in a remote session reported the following error: Processing data from remote server outlook.office365.com failed with the following error message: ERROR_WSMAN_INVALID_SELECTORS: The WS-Management service cannot process the request because the request contained invalid selectors for the resource. For more information, see the about_Remote_Troubleshooting Help topic..
At line:1168 char:5
+ Import-PSSession $Session `
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidResult: (:) [Import-PSSession], RuntimeException
+ FullyQualifiedErrorId : ErrorFromRemoteCommand,Microsoft.PowerShell.Commands.ImportPSSessionCommand
I think this already includes the fixes that you talked about. Any thoughts?
@santoshghimire Please check psrp package version.
@iSazonov Is it 2.3? cannot seem to find PSRP version on my machine. Can you help?
Name Value
---- -----
PSVersion 6.0.2
PSEdition Core
GitCommitId v6.0.2
OS Linux 3.13.0-74-generic #118-Ubuntu SMP Thu De...
Platform Unix
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0...}
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
WSManStackVersion 3.0
Try apt list --installed | grep pspr*
@iSazonov This package is missing. So, I need to install OMI and then psrp, right?
I installed OMI v1.4.2-2 and pspr version is:
omi-psrp-server/trusty,now 1.4.1.28 amd64 [installed]
@iSazonov we need psrp client or psrp server for this? It seems psrp client is still under development.
@santoshghimire Sorry, psrp is server. Client is in PowerShell package. Latest PowerShell version is Preview1 - you could install and tests.
@iSazonov ok. I was confused there. I have installed the latest powershell. I will check if it solves the error.
Just adding a +1 here, I previously had powershell installed and working successfully (which was fabulous!) on a CentOS 7 machine but something broke in the update to 6.1.0 preview 2 (from the MS yum repo) and I now consistently get ERROR_WSMAN_INVALID_SELECTORS when attempting to connect to e.g. Exchange Online.
Downgrading to either 6.0.0_rc.2 or 6.0.2-1, which I know worked once upon a time, now returns the same error after a complete removal and reinstall which rather implies something has also changed at the remote end to tickle this.
My initial testing is showing mixed results on Ubuntu 16.04 - two cases of no return, one of ERROR_WSMAN_INVALID_SELECTORS and the remaining connected.
This 'implies' a server side issue but I want to check out a few more things before jumping to that conclusion.
+1 we are also seeing this on Debian 8 running Powershell v6.0.0. Seems to have started happening in the last week or so.
Has anyone figured out a workaround to this?
While I still think this is a server side issue, I'd like to get a couple of volunteers to try out the latest PSRP bits with their installation. You can do that by installing the latest daily build side-by-side and either using the build directly or by copying libpsrpclient.so and libmi.so to your stable build. There are no API changes but you may want to save off the existing binaries if you take the second approach.
You can get the latest daily build using the tools/install-powershell.ps1 script from the repo:
PS> tools/install-powershell.ps1 -destinaton ~/pstest -Daily
PS> sudo cp ~/pstest/libpsrpclient.so $PSHOME
PS> sudo cp ~/pstest/libmi.so $PSHOME
@dantraMSFT you mentioned you think this is a server-side issue -- is it specific to Linux clients, or would it also affect Windows clients? Our product integration with Exchange invokes PS commands from Debian clients, and we're seeing this error very frequently. Wondering if switching to Windows clients will work around this problem.
@tanaynagjee: Are you seeing the error frequently or always?
@dantraMSFT we are seeing the error frequently, not always. Our setup:
@tanaynagjee: Duration aside, are you finding the error repro's consistently?
Also, would it be possible to do a run using a current daily build that has a newer PSRP? If so, I'll let you know how to do that.
@dantraMSFT sorry for the late reply, was at a conference last week...
Over the last week, we've only seen the error a couple times. We're now discarding/renewing the session when we see the error and that seems to do the trick.
Unfortunately given the way we're set up, we can't run a newer PSRP without some refactoring on our end. Will let you know if we're able to get to that sooner than later.
I’d like to collect some logging from the client side of the connection, if that’s possible.
There is some setup required to get the additional logging.
1: Create the OMI conf directory
• mkdir /etc/opt/omi/conf
2: Create the log directory and ensure user-level access
• mkdir /var/opt/omi/log
• chmod 777 /var/opt/omi/log
3: Create two conf files
• omiserver.conf
o loglevel = DEBUG
• omicli.log
o loglevel = DEBUG
o logpath = /var/opt/omi/log
o logfile = miclient.log
Repro your scenario.
You should see 4 log files under /var/op/omi/log
• miclient.log
• shellclient.log
• omiclient-send.trc
• omiclient-recv.trc
Please send all 4 logs.
@dantraMSFT OK will try and get this set up when we can, and get back to you with the logs once we see the error. Thanks!
@tanaynagjee - actually, it won't be needed. I've been able to repro it here with logging and i believe understand the problem.
Office365 is behind a load balancer but libmi doesn't have logic to save/use the cookie it receives in the response.
Heh, I've been on leave for a few days and was just about to create the debug logs you asked for before I saw the follow-on update about session cookies. Will look forward to the fix :)
I'm working on this out of the OMI tree (https://github.com/Microsoft/omi/issues/523)
Hi, sorry for the OT- any timeline for this being available? will this be part of 6.1.0?
should the status of the issue still be "open" btw? i think it was fixed by @dantraMSFT and just waiting to be merged into release branch?
@yairyog we should only close this issue after it's part of PSCore6
I understand this is now on master- is 6.1.0 previews made from master?
@yairyog The fix is not in Preview4. You can get it with night builds.
@iSazonov Where can I get the night builds with this fix included? Can you point me in the right direction?
Also, when can we expect this fix to be included in the release?
@santoshghimire You can find its on main README page https://github.com/PowerShell/PowerShell#build-status-of-nightly-builds
@santoshghimire if you want to install the daily build, you can also use https://github.com/PowerShell/PowerShell/blob/master/tools/install-powershell.ps1.
.install-powershell.ps1 -daily -destination ...
@iSazonov @dantraMSFT thanks !!
I installed the daily build using install-powershell.ps1 script and I now have _PowerShell 6.1.0-preview.10729_ version which I see was last updated 12 days ago. So, this version includes this fix? How can I be sure?
@santoshghimire Try it out :-) You should get psrp-1.4.5.
Installing PowerShell v6.0.4 on OSX 10.13.3 fixed the problem for me.
Install Link:
https://github.com/PowerShell/PowerShell/releases/download/v6.0.4/powershell-6.0.4-osx.10.12-x64.pkg