title: Use Powershell variable in Batch
body: <pre><code>@echo off
  Powershell.exe -executionpolicy remotesigned -File C:\Users\aborgetti\Desktop\getdate.ps1
  
  FOR /F "usebackq delims=" %%v IN ('powershell -noprofile -File C:\Users\aborgetti\Desktop\getdate.ps1') DO set "d=%%v"
  
  echo %d%
  </code></pre>
  
  <p>This is the part that I am confused about...not really sure how to set the variable from powershell to a variable in the .bat file.</p>
  
  <pre><code> FOR /F "usebackq delims=" %%v IN ('powershell -noprofile -File C:\Users\aborgetti\Desktop\getdate.ps1') DO set "d=%%v"
  </code></pre>
  
  <p>Any help would be much appreciated.</p>
  
  <p><strong>BTW</strong></p>
  
  <p>The $d variable is being used in a set of initial commands for an FTP program called Bluezone FTP 3.2</p>
  
  <p>getdate.ps1 looks like this:</p>
  
  <pre><code>$a = Get-Date
  $b = $a.ToString('MMddyy')
  write-host $b
  </code></pre>