title: How to change a environment variable in PowerShell and launch an application
body: <p>In PowerShell, I need to change the system path variable:</p>
  
  <pre><code>$oldPath = [System.Environment]::GetEnvironmentVariable('Path', 'Machine')
  [System.Environment]::SetEnvironmentVariable('Path', (Transform-It $oldPath), 'Machine')
  </code></pre>
  
  <p>And then launch a program:</p>
  
  <pre><code>&amp; $someExeName 'someargument'
  </code></pre>
  
  <p>The problem I am getting is that the executable is using the old environment. It doesn't recognize the new path. If I also change <code>$env.path</code>, to change the path only for this PowerShell session, it also does not propagate to the new process. If I close PowerShell and launch the executable in a new window, it's fine. Presumably it's inheriting the (non-updated) environment from the PowerShell process.</p>
  
  <p>What is the best practice for changing an environment variable in PowerShell, and having it recognized by new processes launched from that window?</p>