Closed BernieWhite closed 5 years ago
What drive location do we need: that of Powershell runspace, that of the module containing the rule, that of the script calling Invoke-PsRule ? Is the addition of a specific variable to Psrule feasible (needed?) ?
@LaurentDardenne $PWD
is built-in to PowerShell, set to the current working directory. The issue is that the value or $PWD
differs between the runspace calling Invoke-PSRule
and what a rule sees during rule execution.
It doesn't happen in all cases, but I notice the issue when I was trying to load a file from disk within a rule.
Yeah, the fix is to just set the variable inside the rule runspace to match the calling process.
It doesn't happen in all cases, but I notice the issue when I was trying to load a file from disk within a rule.
It is not this case ?
@LaurentDardenne No not in this case. It seems to be related to how the process is run, possibly only affecting PowerShell Core. In this case it was defaulting $PWD
to C:\WINDOWS\System32
.
Description of the issue
$PWD
is not always set as expected during PSRule execution.To Reproduce
Steps to reproduce the issue:
Expected behaviour
$PWD
should use the same path before and during PSRule execution.Module in use and version:
Captured output from
$PSVersionTable
: