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
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -2597,7 +2597,16 @@ internal WSManAPIDataCommon()
#endif

_handle = IntPtr.Zero;
ErrorCode = WSManNativeApi.WSManInitialize(WSManNativeApi.WSMAN_FLAG_REQUESTED_API_VERSION_1_1, ref _handle);

try
{
ErrorCode = WSManNativeApi.WSManInitialize(WSManNativeApi.WSMAN_FLAG_REQUESTED_API_VERSION_1_1, ref _handle);
}
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 :)

}

// input / output streams common to all connections
_inputStreamSet = new WSManNativeApi.WSManStreamIDSet_ManToUn(
Expand Down
8000
Original file line number Diff line number Diff line change
Expand Up @@ -1636,7 +1636,10 @@ All WinRM sessions connected to Windows PowerShell session configurations, such
<data name="InvalidRoleCapabilityFileExtension" xml:space="preserve">
<value>The provided role capability file {0} does not have the required .psrc extension.</value>
</data>
<data name="SSHAbruptlyTerminated" >
<data name="SSHAbruptlyTerminated" xml:space="preserve">
<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.

</data>
</root>
0