title: Invoke-WebRequest produces a corrupt file when downloading from SharePoint using PowerShell
body: <p>I'm trying to download files from our SharePoint locally to my machine using a PowerShell script. When I log into SharePoint and run the following command, I get a corrupt file which is roughly half of the size of the file on SharePoint.
  <code>InvokeWebRequest "https://our.sharepoint.com/Docs/file.pptx" -OutFile out.pptx</code></p>
  
  <p>When I drop <code>-OutFile out.pptx</code> from the command a new Chrome tab opens to <code>https://login.microsoftonline.com/common/cookiesdisabled</code></p>
  
  <p>Any idea of what I'm doing wrong? </p>
  
  <p><a href="https://i.stack.imgur.com/FFtMv.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/FFtMv.png" alt="enter image description here"></a></p>
  
  <p>I've also tried <code>System.Net.WebClient</code> and its <code>DownloadFile</code> but I keep getting a <code>Unathorized 401</code>even when I set the credentials. I guess I'm missing something but I'm not sure what.</p>