1 min read

Categories

Tags

9663950111_c97678228e_m Most people are aware that PowerShell supports commandline navigation in the same way as the good old command prompt (see my previous post Improve PowerShell commandline navigation for ways to enhance this): [code language=”powershell”] cd $env:USERPROFILE\Desktop Resolve-Path ‘.’ #change to the current direction (doing nothing) cd . #move up one level Resolve-Path ‘..’ cd .. [/code] The above is using cd as the alias for the Set-Location Cmdlet providing:

  • One dot as an argument for the Path parameter representing the current location (changing the location to the current location does effectively nothing)

  • Two dots for the Path as an argument for the Path parameter representing one level higher than the current location

Since this is implemented by the Provider (at least that’s what I believe) the same concept can be used in many different places, basically every built-in command that has a Path parameter.: [code language=”powershell”] #get all the built-in commands that have a Path parameter Get-Command | where { $.Parameters -and $.Parameters.ContainsKey(‘Path’) -and $.HelpURI -and $.HelpURI.StartsWith(‘http://go.microsoft.com’) }

#navigation works also with the registry provider cd HKLM:\Software\Microsoft cd .. cd c: #open windows explorer using the current location (ii is the alias for Invoke-Item) ii . #same one level higher ii .. #Within ISE open all files in the current folder or one level higher psedit . psedit .. #copy the current folder and its content to a folder one level higher copy * ..\test [/code] Please share if you know of more tricks using dot(s) as an argument to the Path parameter.

shareThoughts


Photo Credit: Rein -e- Art via Compfight cc