Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Setting Windows PowerShell environment variables

I have found out that setting the PATH environment variable affects only the old command prompt. PowerShell seems to have different environment settings. How do I change the environment variables for PowerShell (v1)?

Note:

I want to make my changes permanent, so I don't have to set it every time I run PowerShell. Does PowerShell have a profile file? Something like Bash profile on Unix?

like image 371
Vasil Avatar asked Apr 03 '09 17:04

Vasil


People also ask

How do I permanently set an environment variable in PowerShell?

Using $env:Path variable in PowerShell to set environment variable for the session or temporary. Use [System. Environment] method in PowerShell to set environment variable permanently.

How do I set the path in Windows PowerShell?

Use $Env:PATH to Set the PATH Environment Variables in Windows PowerShell. Usually, we can set the PATH variable by navigating through the control panel of our operating system. However, inside Windows PowerShell, we can output all our file paths using the $Env:PATH environment variable.

How do I set environment variables in Windows?

On the Windows taskbar, right-click the Windows icon and select System. In the Settings window, under Related Settings, click Advanced system settings. On the Advanced tab, click Environment Variables. Click New to create a new environment variable.


1 Answers

If, some time during a PowerShell session, you need to see or to temporarily modify the PATH environment variable , you can type one of these commands:

$env:Path                             # shows the actual content $env:Path = 'C:\foo;' + $env:Path     # attach to the beginning $env:Path += ';C:\foo'                # attach to the end  
like image 74
mloskot Avatar answered Sep 19 '22 15:09

mloskot