In follow-up to the cmd.exe question, what is the PowerShell equivalent to echo %cd%, or Linux/Unix pwd?

  • in cmd just cd is enough. no need to echo %cd%
    – phuclv
    Feb 27 '17 at 3:58

PowerShell has many of the same commands as Linux. pwd is the command equivalent.

When you type pwd in Powershell, it is an alias to Get-Location.

  • 2
    "that was easy" .. boy do I feel sheepish :)
    – warren
    Jun 9 '11 at 14:03
  • Not exactly, Use Get-Location | Foreach-Object { $_.Path } to get only the path as in Linux pwd Jan 27 at 8:29

In addition to Get-Location and its Aliases, you can also use the automatic variable $pwd.

The $pwd variable is nice because you have direct access to the PathInfo members. E.g.


And if you ever want to know what members there are you can just pipe the command\alias to Get-Member :

PS C:\Users\your-name-here\Desktop> pwd|Get-Member

   TypeName: System.Management.Automation.PathInfo

Name         MemberType Definition
----         ---------- ----------
Equals       Method     bool Equals(System.Object obj)
GetHashCode  Method     int GetHashCode()
GetType      Method     type GetType()
ToString     Method     string ToString()
Drive        Property   System.Management.Automation.PSDriveInfo Drive {get;}
Path         Property   System.String Path {get;}
Provider     Property   System.Management.Automation.ProviderInfo Provider {get;}
ProviderPath Property   System.String ProviderPath {get;}
  • very cool! I need to find a good tutorial introduction to PowerShell
    – warren
    Jun 9 '11 at 14:04
  • 1
    Hover over the Powershell tag in your question. Click the FAQ link. Look at the second item in the list.
    – EBGreen
    Jun 9 '11 at 14:19

It's pwd. You can "stringify" it by putting it in the quotes. More so, you can build up paths like so: "$pwd\bin".

  • elegent,helpful,good.
    – deuterium
    Feb 21 at 17:30

Get-Location cmdlet should do the trick

As Thiago mentioned, you can use these aliases: gl or pwd


If you only need the Path as Text without the usual header:
(gl).Path /* is a short form for Get-Location with the object Path,
or (pwd).Path

  • 1
    Hi Peter and welcome to SU! when indicating stuff that should be typed, use `backticks` (usually the top left corner of QWERTY keyboards below Esc) to put it in code formatting (or for long blocks, indent every line by four spaces) to improve legibility :)
    – Doktor J
    Jan 17 '20 at 19:49

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.