Working Directory
Change Directory
ps1
Set-Location <path>
1
Powershell has three builtin aliases for Set-Location
console
$ Get-Alias -Definition 'Set-Location'
CommandType Name Version Source
----------- ---- ------- ------
Alias cd -> Set-Location
Alias chdir -> Set-Location
Alias sl -> Set-Location
1
2
3
4
5
6
7
2
3
4
5
6
7
Current Working Directory
There's two ways to get current working directory in Powershell.
$PWD
builtinPathInfo
variable. Refreshes on each time location changed.Get-Location
cmdlet. Returns aPathInfo
object.pwd
is an builtin alias forGet-Location
.
ps1
(Get-Location).Path # equivalent to $pwd.Path
1
console
$ Get-Location | select -Property *
Drive Provider ProviderPath Path
----- -------- ------------ ----
D Microsoft.PowerShell.Core\FileSystem
1
2
3
4
5
2
3
4
5