Reputation: 4523
I have a PowerShell script which contains a single command:
pwd
When I execute it from a (Windows 10) command line window, I get the following:
d:\Hudson_Test\workspace\CadGraphics>echo %cd%
d:\Hudson_Test\workspace\CadGraphics
d:\Hudson_Test\workspace\CadGraphics>powershell -file ShowLocation.ps1
Path
----
D:\hudson_test\workspace
As you can see, the current directory moves up one directory (from d:\hudson_test\workspace\CadGraphics to D:\hudson_test\workspace) when inside the PowerShell script.
I tested this on another (Win10) machine, and on that machine, the two paths were the same.
What is going on here, and how can I keep it from happening?
Upvotes: 0
Views: 237
Reputation: 9133
It should not unless the Profile is loading it everytime. Please try with
powershell -NoProfile -File FileName.ps1
Secondly , I would like you to store that in a variable and see the result from write-host
Upvotes: 1