Skip to content

Conversation

@anmenaga
Copy link

@anmenaga anmenaga commented Nov 1, 2019

PR Summary

Implementation for 'Importing Windows PowerShell modules in PowerShell Core' RFC.

  • Modules, that are non-compatible with PS Core and were previously generating PSEditionNotSupported error, are now loaded into a background Windows PowerShell process connected to PS Core using a WinPSCompatSession PS remoting session using redirected process streams transport (same one used by PS jobs).
  • Behaviour can be forced using Import-Module -UseWindowsPowerShell
  • Module autoload during command discovery is supported
  • a warning is displayed when a module is loaded into compat Windows PS.
  • a new telemetry type is added and reported when a module is loaded into compat Windows PS.
  • operations that do not work on de/serialized objects can be done in WinPSCompatSession remoting session $s = Get-PSSession -Name WinPSCompatSession; Invoke-Command -Session $s -ScriptBlock {Get-WinPSLiveObject | Set-WinPSLiveObject}
  • new functionality is under PSWinCompat experimental feature.

Example:
WinCompatCapture

PR Context

PR Checklist

@ghost
Copy link

ghost commented Nov 2, 2019

This PR might impact tooling, because it might be necessary to debug a module imported via compat.

@rjmholt
Copy link
Collaborator

rjmholt commented Nov 2, 2019

$s = Get-PSSession -Name WinPSCompatSession; Invoke-Command -Session $s -ScriptBlock {Get-WinPSLiveObject | Set-WinPSLiveObject}

Given that this is to be a builtin feature, the user experience might be better if encapsulated:

Invoke-InWinPSCompatibilitySession { Get-WinPSLiveObject | Set-WinPSLiveObject }

@rjmholt
Copy link
Collaborator

rjmholt commented Nov 2, 2019

This PR might impact tooling, because it might be necessary to debug a module imported via compat.

@alexbuzzbee could you expand on this with an example? What scenario are you envisaging here? Also, it might be best to have this discussion in the RFC.

@ghost
Copy link

ghost commented Nov 4, 2019

Say you have a script module that was written as Windows-specific (because it uses Windows P/Invokes, COM, or Windows-specific .NET APIs), but need to use it in a modern script. A problem is happening inside the Windows-specific module. You need to debug inside it, so the debugging tools need to be able to see and work inside the Windows PowerShell compat session.

Yes, it might be possible to reproduce the issue using a Windows PowerShell script instead, but that would usually be significantly more effort than just debugging the module.

It might be correct that this should go in the RFC; I was just going off the tooling checkboxes and noted that they might not be accurately filled.

@anmenaga
Copy link
Author

anmenaga commented Nov 4, 2019

@alexbuzzbee Do these examples fall into scenario that you describe?

Debugging from the same PS process:
Dbg1

Debugging from another PS process:
Dbg2

@ghost
Copy link

ghost commented Nov 5, 2019

@anmenaga All I was trying to point out is that the "I have considered the user experience from a tooling perspective and enumerated concerns in the summary" box should probably be checked instead of "I have considered the user experience from a tooling perspective and don't believe tooling will be impacted."

@ghost ghost added Waiting on Author The PR was reviewed and requires changes or comments from the author before being accept and removed Waiting on Author The PR was reviewed and requires changes or comments from the author before being accept labels Nov 5, 2019
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

@daxian-dbw
Copy link
Member

@anmenaga Is this PR ready for review? If so, please remove the WIP: prefix from the title so we can pull in more reviewers.

@anmenaga anmenaga added the Documentation Needed in this repo Documentation is needed in this repo label Nov 13, 2019
@anmenaga anmenaga changed the title WIP: Importing Windows PowerShell modules in PowerShell Core Importing Windows PowerShell modules in PowerShell Core Nov 13, 2019
Copy link
Collaborator

@JamesWTruher JamesWTruher left a comment

Choose a reason for hiding this comment

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

telemetry changes look good

"Alias", "nsn", "New-PSSession", $($FullCLR -or $CoreWindows -or $CoreUnix), "", "", ""
"Alias", "nv", "New-Variable", $($FullCLR -or $CoreWindows -or $CoreUnix), "ReadOnly", "", ""
"Alias", "nwsn", "New-PSWorkflowSession", $($FullCLR ), "ReadOnly", "", ""
"Alias", "nwsn", "New-PSWorkflowSession", $($FullCLR -or $CoreWindows ), "", "", ""
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why do we need the change?

Copy link
Author

Choose a reason for hiding this comment

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

this alias comes from PSWorkflow module which is incompartible with PS Core.
This test just loads all stuff from a hardcoded set of modules and checks against this huge table; PSWorkflow is one of them. With this PR module can actually be successfully loaded on PS Core and the alias shows up, and the test did not expect this.

Copy link
Collaborator

Choose a reason for hiding this comment

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

DefaultCommands.Tests is designed to tracking that is explicitly in PowerShell Core on different platforms and show difference from Windows PowerShell.

If the test failed I guess it is side effect from other tests and just the tests must do right cleanup.

@ghost ghost added Waiting on Author The PR was reviewed and requires changes or comments from the author before being accept and removed Waiting on Author The PR was reviewed and requires changes or comments from the author before being accept labels Nov 14, 2019
@daxian-dbw
Copy link
Member

@anmenaga Can you please resolve the conflict, again :)

@daxian-dbw daxian-dbw added the CL-Engine Indicates that a PR should be marked as an engine change in the Change Log label Nov 18, 2019
@daxian-dbw daxian-dbw merged commit b218e6f into PowerShell:master Nov 18, 2019
@iSazonov
Copy link
Collaborator

Great work @anmenaga !

@ghost
Copy link

ghost commented Nov 21, 2019

🎉v7.0.0-preview.6 has been released which incorporates this pull request.:tada:

Handy links:

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

Labels

CL-Engine Indicates that a PR should be marked as an engine change in the Change Log Documentation Needed in this repo Documentation is needed in this repo MustHave

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants