![]() Let’s consider an example to append a new value to the environment variable using $Env: Path as follows $Env:Path = "C:\go\bin\" To append a new value to an environment variable, use = and specify the variable value. uses EnvironmentVariableTarget as a user to set up an environment for user accounts only.Ĭool Tip: How to run PowerShell as a System account! Append new value to Environment Variable In the above PowerShell script, uses the SetEnvironmentVariable method to set an environment variable permanently for a user and its value will persist permanently. ::SetEnvironmentVariable('GoHugo','C:\Hugo\bin',::User) To create an environment variable permanently for a user account, use method to set an environment variable for a user. PS C:\> Use Powershell to Set Environment Variables for a user CategoryInfo : ObjectNotFound: (GoHugo:String), ItemNotFoundException Get-ChildItem : Cannot find path 'GoHugo' because it does not exist. It will give an error message as the environment variable remains available for that process scope only. ![]() Run the Get-ChildItem command again to get the environment variable created in the above step. ![]() PowerShell set environment variable for the sessionĬlose the PowerShell window and open it again.
0 Comments
Leave a Reply. |