2

In my script, when I do

$env:Path = "Some Path"

and I execute my script within the ISE, $env:Path for the ISE session is now set to "Some Path". I would like to modify the $env:Path for the script only, making it revert back to the original value in the ISE session,after the execution of the script. Right now, I have to close and restart the ISE.

The idea is to change the environment for the scope of my script only. If there is a better idiom in Powershell, please let me know.

1
  • Use the script scope? Commented Mar 7, 2014 at 17:32

1 Answer 1

1

You could always just save the original path, and reset it back at the end of the script...

$origPath = $env:Path
$env:Path = "Some Path"

<script>

$env:Path = $origPath
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.