Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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

share|improve this question
add comment

4 Answers 4

up vote 12 down vote accepted

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.

share|improve this answer
1  
"that was easy" .. boy do I feel sheepish :) –  warren Jun 9 '11 at 14:03
add comment

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.

$pwd.Path.PadLeft(80)
$pwd.Drive

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;}
share|improve this answer
    
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
    
Just what I was looking for! +1 –  javamonkey79 Nov 26 '12 at 23:56
add comment

Get-Location cmdlet should do the trick

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

share|improve this answer
add comment

it's pwd, you can "stringify" it by putting it in the quotes, more so you can build up paths like so "$pwd\bin"

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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