title: Calling PowerShell from batch, and retrieving the new value of a temporary environment variable set in the script?
body: <p>I hope the title is concise, but just in case:</p>
  
  <p>I am calling a PowerShell script from a batch file. I want the PowerShell script to set the value of an environment variable, and for that new value to be available in the batch file when the PowerShell script finishes.</p>
  
  <p>I know that it is possible to set an environment variable using $env in PowerShell, but the value does not persist when the PowerShell script terminates. I imagine this is probably because PowerShell gets executed in a separate process.</p>
  
  <p>I am aware that I can return an exit code and use %ErrorLevel%, but that will only give me numbers, and there will be a conflict, since 1 indicates a PowerShell exception rather than a useful number.</p>
  
  <p>Now, here's the caveat: I don't want the environment variable to persist. That is, I don't want it to be defined for the user or system, and therefore I want it to be unavailable as soon as the batch file exits. Ultimately, I simply want to communicate results back from a PowerShell script to the calling batch file.</p>
  
  <p>Is this possible?</p>
  
  <p>Thanks in advance :)</p>
  
  <p>Nick</p>