title: powershell one liner to download file with credentials
body: <p>I am currently trying to instruct a newly created windows shell to download a powershell script via autounattend.xml file. With that technique, i need a one liner to get the job done.</p>
  
  <p>I used to be able to download them from a public environment using this one-liner :</p>
  
  <pre><code>&lt;Path&gt;powershell -NoLogo -Command "((new-object System.Net.WebClient).DownloadFile('https://some.remote.public.location/myfile.ps1', 'c:\Windows\Temp\myfile.ps1')"&lt;/Path&gt;
  </code></pre>
  
  <p>But now i need to give in proper credentials to download my file from a private location. I tried the following and it doesn't work :</p>
  
  <pre><code>&lt;Path&gt;powershell -NoLogo -Command "((new-object System.Net.WebClient).Credentials = new-object System.Net.NetworkCredential("user123", "password123")).DownloadFile('https://some.remote.private.location/myfile.ps1', 'c:\Windows\Temp\myfile.ps1')"&lt;/Path&gt;
  </code></pre>
  
  <p>(I'm a rookie in powershell :/)</p>
  
  <p>How can i give the proper credentials to the DownloadFile Method in a one liner?</p>
  
  <p>Or is there another command better suited for the job?</p>
  
  <p>Thanks.</p>