Tuesday, April 2, 2013

using Get-Location cmdlet in PowerShell.

Hi everyone.

Sometime, while using our regular or favourite cmdlets, we often forget to use non-regular, non-common cmdlets. When you look in to all cmdlets which powershell offers, you can see there may be few cmdlets which you never used and never notice them.

One of the cmdlet which i came to know is “Get-Location” whose alias is “pwd” (present working directory)

As its name defines , when you run it, it shows your location (not GPS one :D ), it shows you that  in which folder you currently working in.

02-04-2013 17-47-37

this cmdlet is very useful when you want to record you current folder location in to the powershell scripts.

This cmdlet has three main properties.

  1. Path
  2. Drive
  3. Provider

To check these properties we can put Get-Location in to a variable.

$location = Get-Location

02-04-2013 17-49-34

to know the path of the current location we can type $location.Path property.

02-04-2013 17-49-45

To know the name and other information, we can use $location.Drive property.

02-04-2013 17-49-57

to know the PS Provider type, we can use $location.Provide property.

02-04-2013 17-50-11

That’s all for now. :)

Aman Dhally
clip_image001 clip_image002 clip_image003 clip_image005clip_image007

No comments:

Post a Comment