Friday, November 15, 2024
HomeWindowsHow to Find and Reference Environment Variables in Windows PowerShell

How to Find and Reference Environment Variables in Windows PowerShell

In the classic Windows Command Processor, environment variables were referenced using “%” symbols surrounding the variable name. The environment variables were enumerated by simply typing “set” in the command prompt. This has changed considerably in PowerShell.

To find the currently set environment variables, open PowerShell and type the following:

Get-ChildItem Env:

Then to reference one of those items, simply append the “Name” value to $Env: in your command or script. E.g. type the following to change to the windows directory:

cd $env:windir

To elaborate on the options for the Get-ChildItem command, simply prepend it with “help”:

help Get-ChildItem

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Most Popular

LATEST REVIEWS

Recent Comments

error: Content is protected !!