-
Notifications
You must be signed in to change notification settings - Fork 8.1k
Cleanup: remove the unneeded type 'RemotingCommandUtils' #7029
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
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems we can remove the unused code after "else".
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And if it gets removed, this method will just throw when given v2 and do nothing otherwise. I assume that's all the method should do for PowerShell 6?
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, throwing that exception in
#if CORECLRwas a decision when porting the code to NanoServer targeting .NET Core 1.0. Back then, PSv2 was definitely not available on NanoServer, which was the only place that PowerShell Core edition was available, so throwing the exception had no problem. Now PowerShell Core is on the desktop, so I'm not sure if we should just throw the exception there (win 10 has removed PSv2, but downlevel OS still has it as an optional windows feature). Besides, if we decide to go with the exception, we probably need to change the error message.I have updated #3565 to keep track of this cleanup work.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this the behaviour designed to support
powershell.exe -version 2?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@rjmholt I didn't look into why the PSv2 is taken into consideration here, but possibly related to the scenario where the remote server is PSv2.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes that makes sense! Well I suppose the behaviour without the #ifdef makes sense then -- no-op unless trying to remote into v2, in which case, exception.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe we don't support PSv2 at all.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes -- so I'm guessing an exception makes sense then? Something that is red and tells the user we don't support this, but doesn't crash the shell
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems the method is used to run jobs. I guess the remoting (with both local and remote hosts) with PSv2 doesn't work at all.
/cc @PaulHigin Could you please comment too?
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I briefly examined the code that depends on this method.
for the use in
StartJob, it looks to me is possible to start a job running in PSv2 if it's available on the machine. However, in PowerShell Core, we can only start job usingpwsh.So the wholeIt turns out this is a bug that should be fixed. (see PowerShell Core cannot start a job using Windows PowerShell #7059) That means we still need to check for PSv2 availability for-PSVersionparameter doesn't really make sense.Start-Job -PSEdition.for the use in
CustomShellCommand, it allows to register aPSSessionConfigurationfor PSv2.However, PowerShell Core remoting depends on WinRM features from WMF 4.0, so it won't be able to connect to PSv2 remoting endpoint.My comment about the remoting was not accurate. WMF 4.0 is required to create a PSCore endpoint (using PSCore as a server in remoting), however, it might not be required for PSCore to connect to a PSv2 server (using PSCore as a client). If PSCore is able to connect to PSv2 server, then the PSv2 related code is still relevant.So, it looks to me is likely that we still need the PSv2 related code. As to this PR, I think it can be merged as is for now.