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:SoftwareMicrosoftWindowsCurrentVersion
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.IO.File]::WriteAllLines('file.txt', 'Some content')
.NET constructors and methods are an ideal place to use the pwd variable:
[System.IO.File]::WriteAllLines("$pwdfile.txt", 'Some content')
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.140.196.244