How do I get the current directory of the prompt

时间:2015-07-31 20:48:12

标签: powershell

I'm writing a script where the first parameter is a filename. But whenever I try to use that string in something that takes a file, I get an error about the file not being found. How do I get the current directory the powershell prompt is in? For some reason it keeps returning my user profile directory:

C:\Users\user1> [System.IO.Directory]::GetCurrentDirectory()
C:\Users\user1

C:\Users\user1> cd\

C:\> cd temp

C:\temp> [System.IO.Directory]::GetCurrentDirectory()
C:\Users\user1

1 个答案:

答案 0 :(得分:8)

pwd is the cmdlet you search for ;)

This is an alias for Get-Location.