8000 Give error instead of crashing if WSMan client lib not available by SteveL-MSFT · Pull Request #4387 · PowerShell/PowerShell · GitHub
[go: up one dir, main page]

Skip to content

Give error instead of crashing if WSMan client lib not available #4387

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

Merged
merged 2 commits into from
Jul 31, 2017

Conversation

SteveL-MSFT
Copy link
Member
@SteveL-MSFT SteveL-MSFT commented Jul 28, 2017

Affects NanoServer Insider build where WinRM is not available. Currently if user tries invoke-command, powershell crashes.

Validated using:

PS> docker run -it -v C:\users\slee\repos\PowerShell\src\powershell-wincore\bin\Debug\netcoreapp2.0\win10-x64\publish:c:\powershell microsoft/nanoserver-insider-powershell
PS> c:\powershell\powershell
PS> invoke-command -computer . -command { "hello" }

invoke-command : WSMan client library is not installed
At line:1 char:1
+ invoke-command -ComputerName . -Command { "hello" }
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : ResourceUnavailable: (:) [Invoke-Command], PSRemotingTransportException
    + FullyQualifiedErrorId : System.Management.Automation.Remoting.PSRemotingDataStructureException,Microsoft.PowerSh
   ell.Commands.InvokeCommandCommand

Fix #4383

<value>The SSH transport process has abruptly terminated causing this remote session to break.</value>
</data>
<data name="WSManClientDllNotAvailable" xml:space="preserve">
<value>WSMan client library is not installed</value>
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Typo - skipped a point at end.
And may be add short recomendation to user how resolve the problem?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed. It sounds like this only affects Nano. So maybe something like "WSMan client library is not installed. This parameter set requires WSMan for PowerShell remoting commands such as Invoke-Command, New-PSSession, Enter-PSSession." The problem is that SSH remoting may be available if SSH client is installed. But I don't know if that is a likely scenario.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cc @joeyaiello to review error message

This currently only affects Nano, but it's not something easily fixed on Nano. Basically user need to start with a different Nano image that includes WinRM. I don't think we want to put too much detail in the message as it could create more confusion particularly as @PaulHigin pointed out PSRP/SSH could still work if they have ssh.exe (which is probably more likely in the future once OpenSSH port is further along)cc @joeyaiello to review error message

This currently only affects Nano, but it's not something easily fixed on Nano. Basically user need to start with a different Nano image that includes WinRM. I don't think we want to put too much detail in the message as it could create more confusion particularly as @PaulHigin pointed out PSRP/SSH could still work if they have ssh.exe (which is probably more likely in the future once OpenSSH port is further along)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see. Yes I agree that the error message is fine as is.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about "This parameter set requires WSMan, and no WSMan client library is available. WSMan is either not installed or unavailable for this platform. It might also be possible to use SSH-based remoting instead."

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@joeyaiello I'm fine with everything except the last sentence as SSH may or may not be installed. I don't think we need to go to that much detail at this point. Ideally, we should just tell the user run Enable-PSRemoting and magic happens, but that's not anytime soon.

<value>The SSH transport process has abruptly terminated causing this remote session to break.</value>
</data>
<data name="WSManClientDllNotAvailable" xml:space="preserve">
<value>WSMan client library is not installed</value>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed. It sounds like this only affects Nano. So maybe something like "WSMan client library is not installed. This parameter set requires WSMan for PowerShell remoting commands such as Invoke-Command, New-PSSession, Enter-PSSession." The problem is that SSH remoting may be available if SSH client is installed. But I don't know if that is a likely scenario.

Copy link
Contributor
@PaulHigin PaulHigin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

catch (DllNotFoundException)
{
throw new PSRemotingTransportException(
StringUtil.Format(RemotingErrorIdStrings.WSManClientDllNotAvailable));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

StringUtil.Format(..) is unnecessary as no arguments is required for the error message.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

will fix. lazy cut and paste :)

Copy link
Contributor
@joeyaiello joeyaiello left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fine on the SSH pushback, good enough for me.

@daxian-dbw daxian-dbw merged commit cf9f8c8 into PowerShell:master Jul 31, 2017
@SteveL-MSFT SteveL-MSFT deleted the invoke-command branch August 1, 2017 00:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants
0