Import-Module PoshRSJob overwrites $env:PSModulePath on PS Core 6.0.1 due to Add-WindowsPSModulePath incompatibility
codykonior opened this issue · comments
Do you want to request a feature or report a bug?
Incompatibility.
What is the current behavior?
PowerShell Core 6 doesn't include the standard PSModulePath, instead it can be added using the WindowsPSModulePath module and Add-WindowsPSModulePath.
If you do this though and Import-Module PoshRSJob then the path gets lost. This doesn't appear to happen with other modules I tested.
If the current behavior is a bug, please provide the steps to reproduce and if possible a minimal demo of the problem
pwsh
Add-WindowsPSModulePath
Import-Module PoshRSJob
Import-Module PoshRSJob
What is the expected behavior?
The first import works (assuming it's on your path). The second fails because it won't be on the path any longer.
Which versions of Powershell and which OS are affected by this issue? Did this work in previous versions of our scripts?
Name Value
---- -----
PSVersion 6.0.1
PSEdition Core
GitCommitId v6.0.1
OS Microsoft Windows 6.3.9600
Platform Win32NT
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0...}
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
WSManStackVersion 3.0
It's caused by PoshRSJob.psm1
$PoshRS_jobCleanup.Runspace =[runspacefactory]::CreateRunspace()
$PoshRS_jobCleanup.Runspace.Open()
If you uncomment those (which obviously breaks everything) it will load without overwriting the module path. But only if you've modified it using Add-WindowsPSModulePath. If you modified it manually then the path isn't lost.
I'm not sure why the two are different though.
Didn't mean to auto-close this. Definitely want to keep it around to find the root cause of the issue.