Powershell has $PWD
and also Get-Location
, both effectively returning the current "shell location" (as opposed to [System.Environment]::CurrentDirectory
).
$PWD
is documented as:
Contains a path object that represents the full path of the current directory location for the current PowerShell runspace.
And Get-Location
is documented as:
gets an object that represents the current directory, much like the print working directory (pwd) command.
Neither doc page mentions the other option.
So is there any difference in the value they produce? Possibly with multiple runspaces?
@Santiago answered this in the comments:
$pwd
is pretty muchGet-Location
with no parameters, both output$PSCmdlet.SessionState.Path.CurrentLocation
but the cmdlet allows to get your location in different providers, psdrives and stacks