marianleica / azrez

Azure Resource Launcher (azrez) is a console application, created by @marianleica, that aims to support those looking for quick deployments in Azure VMs and Kubernetes for learning and swift repros.
https://github.com/marianleica/azrez
MIT License
1 stars 0 forks source link

setup.ps1 command $env:Path += "C:\azrez\" does not populate env #6

Closed marianleica closed 4 weeks ago

marianleica commented 4 weeks ago

After running $env:Path += "C:\azrez\" on some client machine it does not make the change to the system's environment variables.

marianleica commented 4 weeks ago

This is by design:

When you change environment variables in PowerShell, the change affects only the current session. Ref: https://learn.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_environment_variables?view=powershell-7.4

To change values in the Machine or User scopes, you must use the methods of the System.Environment class. Ref: https://learn.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_environment_variables?view=powershell-7.4#create-persistent-environment-variables-in-windows