Working with providers
Each of the providers shares a common set of commands, such as Set-Location
, Get-Item
, and New-Item
.
Navigating
Set-Location
, which has the alias cd
, is used to navigate around a provider's hierarchy; for example:
Set-Location \ # The root of the current drive
Set-Location Windows # A child container named Windows
Set-Location .. # Navigate up one level
Set-Location ..\.. # Navigate up two levels
Set-Location Cert: # Change to a different drive
Set-Location HKLM:\Software # Change to a specific child container under a drive
Set-Location
may only be used to switch to a container object.
The print working directory (pwd
) variable shows the current location across all providers:
PS> $pwd Path ---- HKLM:\Software\Microsoft\Windows\CurrentVersion
Note
pwd and .NET
:
.NET classes and methods are oblivious to PowerShell's current directory. When the following command is executed, the file will be created in the Start in
path (if a shortcut started PowerShell):[System...