Thraka
Thraka

Reputation: 2164

How do I get the current directory of the prompt

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

Upvotes: 5

Views: 3015

Answers (1)

Martin Brandl
Martin Brandl

Reputation: 58931

pwd is the cmdlet you search for ;)

This is an alias for Get-Location.

Upvotes: 9

Related Questions