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

- Advertisment -

Most Popular

Recent Comments

Cleveland Furia on How to Clear Google Activity
Sid Wohlfarth on How to Clear Google Activity
Riley Magsayo on How to Clear Google Activity
สมัครรับเครดิตฟรี ทันที on How to improve Remote Desktop Protocol Performance
Neal Wangstad on How to Clear Google Activity
Slavcho Andov on How to install Ubuntu
Slavcho Andov on How to fix bad sectors
Sheraz Ali on How to Backup Android