Finding PowerShell’s Current File System Path

To find out the path your PowerShell is currently using, simply run Get-Location:

 
PS> Get-Location

Path          
----          
C:\Users\tobwe
 

However, the current path does not necessarily point to a files system location. If you changed location to the registry, for example, it looks like this:

 
PS> cd hkcu:\ 

PS> Get-Location

Path  
----  
HKCU:\
 

If you need to know the current file system path PowerShell uses, regardless of the current provider you are using, try this:

 
PS> $ExecutionContext.SessionState.Path

CurrentLocation CurrentFileSystemLocation
--------------- -------------------------
HKCU:\          C:\Users\tobwe           



PS> $ExecutionContext.SessionState.Path.CurrentFileSystemLocation

Path          
----          
C:\Users\tobwe 


PS> Get-Location 

Path  
----  
HKCU:\
 

CurrentFileSystemLocation always returns the current location in the file system, which may be different from what Get-Location returns.

Twitter This Tip! ReTweet this Tip!