title: Use Variable insted of Get-Date in powershell
body: <p>I am using <code>PowerShell "(Get-Date).AddDays(-7).ToString('ddMMyyyy')"</code> in batch script.</p>
  
  <p>I want to use a variable instead of <strong>Get-Date</strong> function. Is it possible?</p>
  
  <p><code>ADate</code> is the variable name!</p>
  
  <p><strong>Edited:</strong></p>
  
  <p>As suggested, my script is:</p>
  
  <pre><code>For /F UseBackQ %%A In (
      `PowerShell "(Get-Date).AddDays(-7).ToString('ddMMyyyy')"`
  ) Do Set "Freq=%%A"
  </code></pre>
  
  <p><code>Adate</code> is simple string which comes from the file name, and has a value like <code>16112016</code>.</p>