powershell - Save off env: drive and later revert -


i running multiple scripts powershell console. these scripts add/modify variables in env: drive. between running each script, reset env: drive when opened console. there way save off/copy env: drive, , copy @ later point?

the easiest way start process each script. instead of

.\foo.ps1 

just use

powershell -file .\foo.ps1 

then each script gets own process , own environment mess with. doesn't work, of course, if scripts modify things global variables you'd rather have retained in between.


on other hand, saving state of environment simple:

$savedstate = get-childitem env: 

and restoring again:

remove-item env:* $savedstate | foreach-object { set-content env:$($_.name) $_.value } 

Comments

Popular posts from this blog

How to show in django cms breadcrumbs full path? -

php - Invalid Cofiguration - yii\base\InvalidConfigException - Yii2 -

ruby on rails - npm error: tunneling socket could not be established, cause=connect ETIMEDOUT -