Skip to main content
1 of 12
JaredPar
  • 759.1k
  • 151
  • 1.3k
  • 1.5k

Changing the actual environment variables can be done by using the env: namespace / drive info. For example this code will update the path environment variable

$env:Path = "SomeRandomPath";

There are ways to make environment settings permanent but if you are only using them from PowerShell, it's probably a lot better to use your profile to initiate the settings. On startup, powershell will run any .ps1 files it finds in the WindowsPowerShell directory under my documents. Typically you have a profile.ps1 file already there. The path on my computer is

c:\Users\JaredPar\Documents\WindowsPowerShell\profile.ps1
JaredPar
  • 759.1k
  • 151
  • 1.3k
  • 1.5k