none
How do you set environment variables in Powershell? RRS feed

  • Question

  • My environment variables don't seem to be coming through into Powershell and I'm not sure why.  I need to change my PATH permanently but my changes aren't taking effect.
    Thursday, February 20, 2020 7:34 PM

Answers

  • You would have to change the environment variables with the env: namespace / drive info.
    If you wanted to add something onto your path variable, for example, you'd use something like:
    $env:Path += ";LocationToAdd" (note the += and the ; to demark the previous location).
    To replace the entire path, you'd type something like:
    $env:Path = "LocationToAdd" (Note = and no semi-colon).

    If you want to make these settings permanent, place an anyname.ps1 file somewhere within your Documents folder.
    Powershell will pick it up from there by default.

    Hope this helps!

    Thursday, February 20, 2020 7:37 PM

All replies

  • You would have to change the environment variables with the env: namespace / drive info.
    If you wanted to add something onto your path variable, for example, you'd use something like:
    $env:Path += ";LocationToAdd" (note the += and the ; to demark the previous location).
    To replace the entire path, you'd type something like:
    $env:Path = "LocationToAdd" (Note = and no semi-colon).

    If you want to make these settings permanent, place an anyname.ps1 file somewhere within your Documents folder.
    Powershell will pick it up from there by default.

    Hope this helps!

    Thursday, February 20, 2020 7:37 PM
  • Thanks, yeah, this done the trick. I appreciate it. 
    Thursday, February 20, 2020 8:01 PM
  • How are you making the change.  If you change it in PowerShell then it will not be there after you close PowerShell.

    Take some time to search for documentation that explains what environment variables are and how they work.  There are many blog posts explaing this.

    You can use the control panel "ComputerManagement" to permanently change variables.


    \_(ツ)_/

    Thursday, February 20, 2020 8:07 PM
  • My environment variables don't seem to be coming through into Powershell and I'm not sure why.  I need to change my PATH permanently but my changes aren't taking effect.

    You are leaving out a lot of information, such as specifically how you are making the changes and why you think they are not taking effect.


    -- Bill Stewart [Bill_Stewart]

    Saturday, February 22, 2020 3:06 PM
    Moderator