Navigating Your System


The old Cmd.exe shell primarily provided access to drives, files, and folders on your system. PowerShell provides access to these, but it also provides access to additional resources such as the Windows registry. However, PowerShell "maps" these additional resources so they look like drives, which provides a familiar interface for working with a variety of resources. For example, when you open PowerShell, you might have a prompt that looks something like:

 PS C:\> 

This indicates that PS is currently looking at the root of the C: drive on your system. You can see a list of current drive mappings by using the following Get-PSDrive cmdlet:

 Name       Provider      Root                         CurrentLocation ----       --------      ----                         --------------- A          Microsoft.... A:\ Alias      Microsoft.... C          Microsoft.... C:\                       ...TEM\MSMAPI\1033 cert       Microsoft.... \ D          Microsoft.... D:\ Env        Microsoft.... F          Microsoft.... F:\ Function   Microsoft.... HKCU       Microsoft.... HKEY_CURRENT_USER HKLM       Microsoft.... HKEY_LOCAL_MACHINE Variable   Microsoft.... 

Notice that drive names aren't limited to single letters. For example, the HKLM drive maps to the HKEY_LOCAL_MACHINE portion of the registry. Also notice the Provider column, which indicates the PowerShell provider or piece of software providing the connectivity to that particular resource. Providers are what make PowerShell so flexible. By simply adding a provider, you can gain access to entirely new resources through PowerShell. In addition to internal providers for aliases, functions, and variables, PowerShell ships with providers that give you access to certificates (the cert provider), the registry (HKCU and HKLM), the filesystem (drive letters), and the Windows environment (the env provider).

Additional Providers

Additional providers are available for Microsoft Visual SourceSafe and SharePoint services. Other providers will be available in the future, although these won't be covered or referenced in this book.

To change locations, simply use the Set-Location cmdlet, passing it the name of the location you want to change to as shown below.

 PS C:\>Set-Location HKLM:\ 

Don't Worry About the Case

PowerShell is generally case-insensitive, so Set-Location is the same as set-location.

Note that you can set yourself directly to a complete location as follows:

 PS C:\>Set-location "C:\Documents and Settings" 

This will change the shell's focus directly to the indicated path. Note that the path is contained within double quotation marks because any argument that contains spaces must be enclosed within double quotation marks.

PowerShell also maintains a stack of locations. Think of the stack as a big pile of location names on top of one another. You can add or push the current location onto the top of the stack by using the Push-Location cmdlet. If you specify a path, you'll push the current location, and then change to the specified path. You can quickly change to the location on the top of the stack by using the Pop-Location cmdlet. For example, the following cmdlet moves the location C:\ to the top of the stack and changes to the C:\Test directory.

 PS C:\>Push-Location C:\Test 

Later, when you're ready to quickly change back to C:\, issue the following cmdlet:

 PS C:\Documents and Settings>Pop-Location 

Learning to navigate through the PowerShell shell quickly is a key to using it effectively.



Windows PowerShell. TFM
Internet Forensics
ISBN: 982131445
EAN: 2147483647
Year: 2004
Pages: 289

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net