Contact Info

Crumbtrail » Administration » Powershell » Powershell 2.0 » Get-Location

Get-Location - Powershell 2.0 CmdLet

Microsoft Windows PowerShell is a command-line shell and scripting tool based on the Microsoft .NET Framework. It is designed for system administrators, engineers and developers to control and automate the administration of Windows and applications.

More than hundred command-line tools (so called "cmdlets") can be used to perform system administration tasks and Windows Management Instrumentation (WMI). These cmdlets are easy to use, with standard naming conventions and common parameters, and standard tools for piping, sorting, filtering, and formatting data and objects.


Short description
Gets information about the current working location.

Get-Location [-PSDrive <string[]>] [-PSProvider <string[]>] [-UseTransaction] [<CommonParameters>]

Get-Location [-Stack] [-StackName <string[]>] [-UseTransaction] [<CommonParameters>]

The Get-Location cmdlet gets an object that represents the current directory, much like the pwd (print working dire
ctory) command. 

When you move between Windows PowerShell drives, Windows PowerShell retains your location in each drive. You can us
e Get-Location to find your location in each drive.

You can also use Get-Location to get the current directory at run time and use it in functions and scripts, such as
 in a function that displays the current directory in the Windows PowerShell prompt.

If you use the Push-Location cmdlet to add locations to a path stack, you can use the Stack parameter of Get-Locati
on to display the current stack.