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

ERROR_WSMAN_INVALID_SELECTORS #3771

Closed
michelderooij opened this Issue May 12, 2017 · 38 comments

Comments

@michelderooij

michelderooij commented May 12, 2017

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

Steps to reproduce

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

Expected behavior

Connection to Office 365 session.

Actual behavior

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

  • Import-PSSession -Session $Session
  •   + CategoryInfo          : InvalidResult: (:) [Import-PSSession], RuntimeException
      + FullyQualifiedErrorId : ErrorFromRemoteCommand,Microsoft.PowerShell.Commands.ImportPSSessionCommand
    
    

Environment data

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

@iSazonov

This comment has been minimized.

Collaborator

iSazonov commented May 12, 2017

@michelderooij Thanks for the Issue report!

/cc @PaulHigin Could you please comment the Issue?

@pvaillant

This comment has been minimized.

pvaillant commented Jun 9, 2017

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

@MPW1412

This comment has been minimized.

MPW1412 commented Mar 28, 2018

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

@SteveL-MSFT SteveL-MSFT added this to the 6.1.0-Consider milestone Mar 28, 2018

@SteveL-MSFT

This comment has been minimized.

Member

SteveL-MSFT commented Mar 28, 2018

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

@santoshghimire

This comment has been minimized.

santoshghimire commented Apr 3, 2018

@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?

@iSazonov

This comment has been minimized.

Collaborator

iSazonov commented Apr 3, 2018

@santoshghimire Please check psrp package version.

@santoshghimire

This comment has been minimized.

santoshghimire commented Apr 3, 2018

@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 
@iSazonov

This comment has been minimized.

Collaborator

iSazonov commented Apr 3, 2018

Try apt list --installed | grep pspr*

@santoshghimire

This comment has been minimized.

santoshghimire commented Apr 3, 2018

@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]

@santoshghimire

This comment has been minimized.

santoshghimire commented Apr 3, 2018

@iSazonov we need psrp client or psrp server for this? It seems psrp client is still under development.

@iSazonov

This comment has been minimized.

Collaborator

iSazonov commented Apr 3, 2018

@santoshghimire Sorry, psrp is server. Client is in PowerShell package. Latest PowerShell version is Preview1 - you could install and tests.

@santoshghimire

This comment has been minimized.

santoshghimire commented Apr 3, 2018

@iSazonov ok. I was confused there. I have installed the latest powershell. I will check if it solves the error.

@PaulHigin

This comment has been minimized.

Contributor

PaulHigin commented Apr 3, 2018

@greem

This comment has been minimized.

greem commented May 9, 2018

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.

@dantraMSFT

This comment has been minimized.

Contributor

dantraMSFT commented May 11, 2018

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.

@bqumsiyeh

This comment has been minimized.

bqumsiyeh commented May 16, 2018

+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?

@dantraMSFT

This comment has been minimized.

Contributor

dantraMSFT commented May 16, 2018

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

@tanaynagjee

This comment has been minimized.

tanaynagjee commented May 16, 2018

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

@dantraMSFT

This comment has been minimized.

Contributor

dantraMSFT commented May 16, 2018

@tanaynagjee: Are you seeing the error frequently or always?

@dantraMSFT dantraMSFT closed this May 16, 2018

@dantraMSFT dantraMSFT reopened this May 16, 2018

@tanaynagjee

This comment has been minimized.

tanaynagjee commented May 17, 2018

@dantraMSFT we are seeing the error frequently, not always. Our setup:

  • We schedule PowerShell tasks to run on a Debian 8 container running PS v6.0.0.
  • If we restart the session, things seem to work fine for a while. After some quiet time (we're not quite sure what the threshold is here), requests start to fail with ERROR_WSMAN_INVALID_SELECTORS. Once we get the error, it’ll continue to repeat until we discard the session.
@dantraMSFT

This comment has been minimized.

Contributor

dantraMSFT commented May 23, 2018

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

@tanaynagjee

This comment has been minimized.

tanaynagjee commented May 29, 2018

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

@dantraMSFT

This comment has been minimized.

Contributor

dantraMSFT commented May 29, 2018

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.

@tanaynagjee

This comment has been minimized.

tanaynagjee commented May 29, 2018

@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!

@dantraMSFT

This comment has been minimized.

Contributor

dantraMSFT commented May 29, 2018

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

@greem

This comment has been minimized.

greem commented Jun 4, 2018

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 :)

@dantraMSFT

This comment has been minimized.

Contributor

dantraMSFT commented Jun 27, 2018

I'm working on this out of the OMI tree (Microsoft/omi#523)

@yairyog

This comment has been minimized.

yairyog commented Jul 12, 2018

Hi, sorry for the OT- any timeline for this being available? will this be part of 6.1.0?

@yairyog

This comment has been minimized.

yairyog commented Jul 12, 2018

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?

@SteveL-MSFT

This comment has been minimized.

Member

SteveL-MSFT commented Jul 12, 2018

@yairyog we should only close this issue after it's part of PSCore6

@yairyog

This comment has been minimized.

yairyog commented Jul 26, 2018

I understand this is now on master- is 6.1.0 previews made from master?

@iSazonov

This comment has been minimized.

Collaborator

iSazonov commented Jul 26, 2018

@yairyog The fix is not in Preview4. You can get it with night builds.

@santoshghimire

This comment has been minimized.

santoshghimire commented Aug 12, 2018

@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?

@iSazonov

This comment has been minimized.

Collaborator

iSazonov commented Aug 13, 2018

@dantraMSFT

This comment has been minimized.

Contributor

dantraMSFT commented Aug 13, 2018

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

@santoshghimire

This comment has been minimized.

santoshghimire commented Aug 14, 2018

@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?

@iSazonov

This comment has been minimized.

Collaborator

iSazonov commented Aug 14, 2018

@santoshghimire Try it out :-) You should get psrp-1.4.5.

@ssstonebraker

This comment has been minimized.

ssstonebraker commented Aug 21, 2018

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment