title: How to download a file with Powershell System.Net.WebClient and custom user-agent string?
body: <p>I am running the following command to download a file using the Powershell System.Net.WebClient method:</p>
  
  <pre><code>powershell -Command "(New-Object System.Net.WebClient).DownloadFile('https://domain.name/file.name','C:\file.name')"
  </code></pre>
  
  <p>Is there a way to customize the user-agent and to also retain the one-line command format?</p>
  
  <p>Reason I'm asking is because the website recognizes the request as coming from a bot, and I'm getting an HTTP 403 forbidden error. When I use Internet Explorer, I can download the file without issues. I'd like to keep the one-line format because this command is being called from a batch (.bat) file in Windows.</p>