title: How to download a file to $env:temp directory using powershell from cmd console?
body: <p>I can download a file to a constant location from cmd console using powershell like this</p>
  
  <pre><code>C:\Users\Weijun&gt;powershell -command "(new-object System.Net.WebClient).DownloadFile('https://example.com/example.zip', 'D:\example.zip')"
  </code></pre>
  
  <p>but i need to download it to system temp directory,using the powershell variable <code>$env:temp</code>,the following doesn't work.(variable not expanded in single-quote)</p>
  
  <pre><code>powershell -command "(new-object System.Net.WebClient).DownloadFile('https://example.com/example.zip', '$env:temp\example.zip')"
  </code></pre>
  
  <p>how to pass variable as parameter in method invoke?</p>
  
  <p><strong>UPDATE:</strong> it is a typo for <code>$env:temp:</code>,I amend it.</p>