Chapter 5. Working with the File System, Registry, and Variables

One of the most powerful features of Windows PowerShell is the ability to navigate through many different data stores in a consistent manner. In addition to the familiar file system drives, such as C: and D:, Windows PowerShell includes drives that represent the registry hives, variables, aliases, environment variables, functions, certificates, and more. This chapter demonstrates how to work with four drives: the File System drive, the Registry drive, the Variable drive, and the Environment drive.

More specifically, this chapter covers the following topics:

  • Using Get-PSDrive and Get-PSProvider to retrieve Windows PowerShell drives and providers

  • Working with the file system

  • Working with the registry

  • Working with variables

  • Working with environment variables

Using Get-PSDrive and Get-PSProvider

You can use the cmdlet Get-PSDrive to obtain a list of all Windows PowerShell drives. Run the following command at the Windows PowerShell prompt:

Get-PSDrive | Format-Table –auto

Figure 5-1 shows the list of drives on a default installation of Windows PowerShell. In this example, all of the following are on the local machine: one alias drive, which contains aliases for commands; one certificate drive, cert:, which contains digital signature certificates; three file system drives, C:, D: and E:; one environment drive, Env:, which contains environmental variables; one function drive, Function:, which contains functions declared in PowerShell; ...

Get Microsoft® SQL Server® 2008 Administration with Windows PowerShell™ now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.