Set the current PowerShell working location.

      Set-Location [[-path] string] [-passThru]
         [-UseTransaction] [CommonParameters]

      Set-Location [-literalPath] string] [-passThru]
         [-UseTransaction] [CommonParameters]

      Set-Location [-stackName string] [-passThru]
         [-UseTransaction] [CommonParameters]

   -path string
       The path to a new working location.

   -literalPath string
       Like Path above, only the value is used exactly as typed.
       No characters are interpreted as wildcards. If the path includes any
       escape characters then enclose the path in single quotation marks.
       The stack to which the location is being set.

       Pass the object created by this cmdlet through the pipeline.

       Include the command in the active transaction.

       -Verbose, -Debug, -ErrorAction, -ErrorVariable, -WarningAction, -WarningVariable,
       -OutBuffer -OutVariable.

Standard Aliases for Set-Location: cd, chdir, sl

Non-PowerShell utilities

PowerShell Location is not the same as the Current Directory, used by Non-PowerShell utilities such as RoboCopy.
However Current Directory is available as a static environment variable:

Read the System.Environment's CurrentDirectory property:

Set the System.Environment's CurrentDirectory property:
[environment]::CurrentDirectory = "C:\music\mp3"

The CMD shell's working directory does not automatically follow the current location of PowerShell for security reasons, older command-line applications may try to load certain DLLs from the current directory.


Set the current location to HKLM in the registry provider:

PS C:\> set-location HKLM:

Set the current location to the environment variable provider:

PS C:\> set-location env: -passthru

Set the current location to the C:\ drive in the FileSystem provider:

PS C:\> set-location C:

“The three most important factors in buying a home are, location, location, location!”


Get-Location - Get and display the current location
- Set the current working location (from the stack)
- Push a location to the stack
Equivalent bash command: cd - Change Directory

Copyright © 1999-2017
Some rights reserved