'In powershell, how can I define all env vars for the next command similar to python's Popen abilities?

In powershell, how can I...

  • explicitly define all the env vars for the next command?
  • I don't want any system env vars if possible,
  • After this command runs I dont want anything we have done to affect further processes in the shell.

As an example, in python we have the equivalent ability in Popen to pass a dictionary of the full environment to the subprocess, and I'm hoping there might be something similar in Powershell.



Solution 1:[1]

I think this link explains what you need: Windows user environment variable vs. system environment variable

[Environment]::GetEnvironmentVariable("TEMP", "Machine")

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Technoob1984