21.2. The Environment Command Shell Provider

Access to environment variables from Windows PowerShell depends on the Environment command shell provider. The Environment command shell provider is the interface between Windows PowerShell and the data store for environment variables. The env: drive containing environment variables is supported by the Environment command shell provider and is the only drive related to it. The env drive contains the information about all currently configured environment variables.

To display information about the Environment provider, use this command:

get-psprovider -PSProvider Environment |
format-list

The information displayed by the preceding commands is shown in Figure 21-7. As you can, see the Environment provider supports a single drive, env.

Figure 21.7. Figure 21-7

To display the current help file about the Environment provider, use this command:

Help Environment

To display information about the Env drive, use this command:

get-psdrive Env |
format-list

Although Env is a drive, be careful not to include a colon character in the preceding command after the drive name. Figure 21-8 shows the information displayed about the Env drive after executing the preceding command.

Figure 21.8. Figure 21-8

Get Professional 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.