get-location — Print the current directory — pwd equivalent across all 5 shells
Equivalents in every shell
pwdBuiltin. Prints `$PWD` — the logical path (with symlinks unresolved). Pass `-P` for the physical path (canonicalised). The exit status is always 0.
pwdBuiltin. Same `-L` (logical, default) / `-P` (physical) flags as bash. The special parameter `$PWD` is updated atomically by `cd`, so `${PWD:A}` resolves symlinks without forking.
pwdBuiltin. `pwd -P` for physical path; `pwd -L` for logical (default). Also exposed as `$PWD`; the abbreviation hook can rewrite long paths to `~/…` for prompt display.
Get-LocationAliased as `pwd`, `gl`. Returns a `[PathInfo]` object — `.Path` is the string, `.Provider` is the PowerShell provider (FileSystem, Registry, Certificate). For just the string, use `(Get-Location).Path` or the automatic variable `$PWD`.
cdcmd has no separate `pwd` — bare `cd` (no arguments) prints the current path. Inside batch files, `%CD%` is the equivalent variable. Both forms always reflect the file-system path (no provider concept).
Worked examples
Print the current working directory
pwdGet-LocationcdCapture cwd into a variable
here=$(pwd)set here (pwd)$here = (Get-Location).Pathset here=%CD%Resolve symlinks in the cwd path
pwd -Pecho ${PWD:A}(Resolve-Path .).PathGotchas
- `Get-Location` returns a `[PathInfo]` object — string-comparing it directly (`(Get-Location) -eq 'C:\foo'`) compares the type-coerced `.ToString()`, which usually works but is surprising. Pull `.Path` explicitly for safety: `(Get-Location).Path -eq 'C:\foo'`.
- `$PWD` is the same `[PathInfo]` value — assigning `$PWD = 'C:\bar'` does NOT change directory (it shadows the variable in the current scope). Use `Set-Location` to actually change cwd.
- Inside a non-FileSystem provider (registry, cert), `Get-Location` still returns sensibly — e.g. `Microsoft.PowerShell.Core\Registry::HKEY_LOCAL_MACHINE\Software`. Scripts that pass `(Get-Location).Path` to file APIs blow up when the user is `cd`'d into the registry.
- On Windows, `Get-Location` preserves the user's drive-letter casing as typed (`C:\` vs `c:\`); on Linux/macOS pwsh, the path is always returned with the OS-native casing. Don't rely on the case for equality comparisons.
- `pwd` (the alias) is shadowed by the system binary `/bin/pwd` on Linux/macOS pwsh hosts only if you call it via `& pwd` (forces external lookup). Bare `pwd` always resolves to the alias first — same behaviour as the Windows `cd` shadowing.