Chapter 21. Working with Environment Variables

Like the file system and registry, Windows PowerShell provides a command shell provider and corresponding drive that allows you to explore and manipulate environment variables. An environment variable is a value that can affect how the operating system or processes run.

Working with environment variables is simpler in some respects than working with the file system or the registry, since the environment variables are not stored in a hierarchy inside the env drive unlike the hierarchy of objects in the file system or registry. In the env drive, it is as if all Windows files were stored in the root folder. It is inappropriate, then, for example, to use the Recurse parameter when using the get-childitem cmdlet in the env drive that you might use with a drive associated with the FileSystem provider.

Another limitation when using the env drive is that you cannot make permanent changes in environment variables. Changes you make to environment variables are limited to the duration of the relevant MSH session and apply only to that session.

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.