In PowerShell, where are environment variables stored?

Study for the SANS560 GIAC Penetration Tester (GPEN) Test. Study with flashcards and multiple choice questions, each question has hints and explanations. Get ready for your exam!

Multiple Choice

In PowerShell, where are environment variables stored?

Explanation:
In PowerShell, environment variables are stored in the current process’s environment block and are exposed to you through the environment provider as a PSDrive named env:. You can list them with Get-ChildItem env: or access a specific one with $env:NAME. This is why the environment variables appear in PowerShell as a separate namespace rather than as regular PowerShell variables or as registry keys. The PATH example, accessible as $env:PATH, shows how these live in the process context and are inherited by any child processes launched from that PowerShell session. If you want to persist changes across sessions, you’d have to write to the registry (or use tools like setx) rather than simply setting $env: variables, which only affect the current process.

In PowerShell, environment variables are stored in the current process’s environment block and are exposed to you through the environment provider as a PSDrive named env:. You can list them with Get-ChildItem env: or access a specific one with $env:NAME. This is why the environment variables appear in PowerShell as a separate namespace rather than as regular PowerShell variables or as registry keys. The PATH example, accessible as $env:PATH, shows how these live in the process context and are inherited by any child processes launched from that PowerShell session. If you want to persist changes across sessions, you’d have to write to the registry (or use tools like setx) rather than simply setting $env: variables, which only affect the current process.

Subscribe

Get the latest from Passetra

You can unsubscribe at any time. Read our privacy policy