Refreshes/reloads the environment variables in the current PowerShell session.
No need to close and reopen PowerShell.
This script is derived from Chocolatey's helper functions. The functions have been combined them into one script and some additional functionality has been added. Chocolatey is not required to run Rrefresh-EnvironmentVariables
.
Per the Apache 2.0 license, the original license is included in the script along with the original author attribution, copyright, and changes. To keep things simple, the same license is used in this script. More info
Please install the latest version using Install-Script
or the PS1
file from Releases. The version on the repo itself may be under development and not work as expected.
Open PowerShell as Administrator and type
Install-Script Refresh-EnvironmentVariables -Force
Follow the prompts to complete the installation (you can tap A
to accept all prompts or Y
to select them individually.
Note: -Force
is optional but recommended, as it will force the script to update if it is outdated.
The script is published on PowerShell Gallery under Refresh-EnvironmentVariables
.
If you want to trust PSGallery so you aren't prompted each time you run this command, or if you're scripting this and want to ensure the script isn't interrupted the first time it runs...
Install-PackageProvider -Name "NuGet" -Force
Set-PSRepository -Name "PSGallery" -InstallationPolicy Trusted
- Download the latest Refresh-EnvironmentVariables.ps1 from Releases
- Run the script with
.\Refresh-EnvironmentVariables.ps1
In PowerShell, type
Refresh-EnvironmentVariables
If you want to add an alias to the command, you can add the following to your PowerShell profile:
New-Alias -Name RefreshEnv -Value Refresh-EnvironmentVariables
Aliases take precedence over functions, cmdlets, and exe/bat/cmd files, so you can type RefreshEnv
instead of Refresh-EnvironmentVariables
. The reason we did not make this the default is that to avoid naming conflicts with Chocolatey's refreshenv
cmd script.
No parameters are required to run the script, but there are some optional parameters to use if needed.
Parameter | Required | Description |
---|---|---|
-CheckForUpdate |
No | Checks if there is an update available for the script. |
-Version |
No | Displays the version of the script. |
-Help |
No | Displays the full help information for the script. |
If you're like to help develop this project: fork the repo, make your changes, and submit a pull request. 😊