reflush EnvironmentVariable in powershell without interrupt current shell RRS feed

  • Question

  • I use [Environment]::SetEnvironmentVariable() method to creat a EnvironmentVariable in a powershell session,how can i reflush EnvironmentVariable in current  shell session like the commond source in linux ,to perform reread the config file without interrupt current  shell 
    Sunday, November 17, 2019 8:33 AM

All replies

  • Three is no such command in PowerShell. Environment variables are not stored in a config file.

    There are really no similarities between Linux shells and Windows.  Linux is mostly a file based system and Windows uses other methods like databases and a registry to manage settings.

    You can just exit PowerShell and environment variables that you se will be removed.

    To create or remove a temporary environment variable do the following:

    New-Item -path env:\  -Name testme2 -Value 10
    Remove-Item -path env:\testme2


    Sunday, November 17, 2019 8:45 AM
  • You can remove all environment variables in a PS Session like this:

    del env:\*


    Sunday, November 17, 2019 8:48 AM