I know why this is happening given how #11057 was implemented. Is there any sort of workaround, other than explicitly resetting the PSModulePath in the Windows Powershell script?
Steps to reproduce
- Set up invocation of powershell.exe in some sort of non-PS tool. In my case, a post-action on a
dotnet new template.
{
"actionId": "3A7C4B45-1F5D-4A30-959A-51B88E82B5D2",
"args": {
"executable": "powershell",
"args": "-File init.ps1 "
},
"manualInstructions": [{
"text": "Run 'init.ps1'"
}],
"continueOnError": false,
"description ": "Initializes something."
}
- Invoke the above from pwsh.
Expected behavior
powershell.exe has correct PSModulePath.
Actual behavior
powershell.exe still has PS7 values in PSModulePath.
C:\path\to\init.ps1 : C:\Users\nwe\Documents\PowerShell\Modules;C:\Program Files\PowerShell\Modules;c:\program
files\powershell\7\Modules;C:\Program Files\WindowsPowerShell\Modules;C:\WINDOWS\system32\WindowsPowerShell\v1.0\Modules;C:\Program Files (x86)\Microsoft SQL
Server\140\Tools\PowerShell\Modules\
Environment data
Name Value
---- -----
PSVersion 7.0.2
PSEdition Core
GitCommitId 7.0.2
OS Microsoft Windows 10.0.18363
Platform Win32NT
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
WSManStackVersion 3.0
I know why this is happening given how #11057 was implemented. Is there any sort of workaround, other than explicitly resetting the PSModulePath in the Windows Powershell script?
Steps to reproduce
dotnet newtemplate.Expected behavior
powershell.exe has correct PSModulePath.
Actual behavior
powershell.exe still has PS7 values in PSModulePath.
Environment data