Get Location - PowerShell


The Get-Location command in PowerShell retrieves the current working directory in the file system. It allows you to easily determine which directory you’re currently navigating within PowerShell.


Get-Location [[-Provider] <string>] [[-LiteralPath] <string>]


| Option | Description | Default |
| -Provider | Specifies the location provider from which to retrieve the path. | FileSystem |
| -LiteralPath | Retrieves the current working directory as a literal path, even if it contains special characters. | $false |


Simple usage: Retrieve the current working directory:


Retrieve the current working directory as a literal path:

Get-Location -LiteralPath

Get the current working directory from a specific provider:

Get-Location -Provider HKLM

Common Issues

Error: “The term ‘Get-Location’ is not recognized.”

This error occurs if the Get-Location module is not installed. Run the following command to install it:

Install-Module PSReadLine -Force


The Get-Location command can be used in conjunction with other PowerShell commands to automate various tasks. For example:

Get-Location | Set-Location $home

This command chain navigates to the current user’s home directory.

  • Set-Location: Sets the current working directory.
  • cd: An alias for Set-Location.