Windows PowerShell Home
PSScriptRoot in ps1 script in PSv3 is empty in ISE
10/31/2012 1:56:02 PM
User(s) can reproduce this bug
In the PSv3 documentation, $PSScriptRoot is now an automatic variable that is populated for both modules and ps1 scripts. It works from PowerShell.exe but not from the ISE
How often does this happen?
Have you seen this problem before in this product?
I don't know if this issue existed previously
1. Create a new script (eg c:\test.ps1) with the contents: gv PSScriptRoot
2. From PowerShell.exe, execute the script and see PSScriptRoot has a value.
3. From the ISE Console pane, execute the script and see PSScriptRoot had a value.
4. Open the script file in the ISE Script Pane and press F5 to run the script and see PSScriptRoot is blank.
The $PSScriptRoot automatic variable should have a value when run via F5 in the ISE.
to post a comment.
Please enter a comment.
on 10/31/2012 at 4:32 PM
I could reproduce it
However even in that situation
$myVar = $PSScriptRoot
works as expected and the correct value is set to $myVar
to post a workaround.
Please enter a workaround.
© 2014 Microsoft