title: How can I source variables from a .bat file into a PowerShell script?
body: <p>I'm replacing parts of a .bat script with PowerShell. Configuration for the batch files is done via files that <code>set</code> appropriate environment variables. I'm looking for a way to load those variable values into the <code>.ps1</code> script, without modifying the <code>.bat</code> files (as they are also used in other places.</p>
  
  <p>An example <code>.bat</code> looks as follows:</p>
  
  <pre><code>set VAR_ONE=some_value
  set VAR_TWO=/other-value
  </code></pre>
  
  <p>In a batch script, I'd just <code>CALL</code> the configuration file and the variables would be available. I've tried both dot-sourcing (<code>. filename.bat</code>) and calling (<code>&amp; filename.bat</code>) the configuration files from PowerShell, neither of those makes the variables visible. Tried accessing them with both with <code>$VAR_ONE</code> and <code>$env:VAR_ONE</code> syntax.</p>
  
  <p>What would be a good way to load such configuration file without modifying it's format on disk?</p>