title: How to call an executable with parameters from powershell script
body: <p>I am seeking help on how to call cmd with specific parameters from a powershell script. So far what I have written is below, but it gives me an error message saying $_cmd is not recognized.</p>
  
  <p>I am trying to pass the from date and to date to a an exe... The from date as you can see needs to be today - 1 and the to date should be now. The path of the executable is D:\DataService and that's why I am setting the path early in the script. </p>
  
  <pre><code>    Write-Host "Get data from service"
  
  $path ="D:\DataService"
  
  Push-Location $path
  $Date = Get-Date
  $DateFrom = $Date.ToString("yyyy-MM-dd HH:mm:ss")
  $DateTo = $Date.AddDays(-1).ToString("yyyy-MM-dd")
  $_cmd = "ReportGen.exe -ReportType Data -DateFrom $DateFrom $DateTo"
  
  %$_cmd%
  </code></pre>
  
  <p>Any suggestions please? </p>