Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Yes, the current directory can be retrieved using the built-in variable $PWD (Print Working Directory) in PowerShell.

Here's an example:

$currentDirectory = $PWD.Path
Write-Host "The current directory is: $currentDirectory"

This will output something like:

The current directory is: C:\Users\Username\Documents\PowerShell\Scripts