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

html - Difficulties with background-image property -

visual studio code - What does the isShellCommand property actually do and how should you use it? -

ios - Segue not passing data between ViewControllers -