title: Download URL content using PowerShell
body: <p>I am working in a script, where I am able to browse the web content or the 'url' but I am not able to copy the web content in it &amp; download as a file.
  This is what I have made so far:</p>
  <pre><code>$url = &quot;http://sp-fin/sites/arindam-sites/_layouts/xlviewer.aspx?listguid={05DA1D91-F934-4419-8AEF-B297DB81A31D}&amp;itemid=4&amp;DefaultItemOpen=1&quot;
  $ie=new-object -com internetexplorer.application
  $ie.visible=$true
  $ie.navigate($url)
  while($ie.busy) {start-sleep 1} 
  </code></pre>
  <p>How can I copy the content of <code>$url</code> and save it to local drive as a file?</p>
  <h3>Update:</h3>
  <p>I got these errors:</p>
  <blockquote>
  <p>Exception calling &quot;DownloadFile&quot; with &quot;2&quot; argument(s): &quot;The remote server returned an error: (401) Unauthorized.&quot; At :line:6 char:47 + (New-Object system.net.webclient).DownloadFile( &lt;&lt;&lt;&lt; &quot;$url/download-url-content&quot;, 'save.html' )</p>
  <p>Missing ')' in method call. At :line:6 char:68 + (New-Object system.net.webclient).DownloadFile( &quot;$url&quot;, 'save.html' &lt;&lt;&lt;&lt;</p>
  <p>Exception calling &quot;DownloadFile&quot; with &quot;2&quot; argument(s): &quot;The remote server returned an error: (401) Unauthorized.&quot; At :line:6 char:47 + (New-Object system.net.webclient).DownloadFile( &lt;&lt;&lt;&lt; &quot;$url&quot;, 'save.html' )</p>
  </blockquote>
  <p>Ok, let me explain more, on what I am trying to do: I have a excel file in our share point site &amp; this is the file I am trying to download locally(any format), which is a part of the script, so that for the later part of the script, I can compare this file with other data &amp; get an output.</p>
  <p>Now if I can somehow map &quot;my documents&quot; from the site &amp; able to download the file, that will also work for me.</p>