title: Using Powershell to download files from Google Drive
body: <p>So, I'm currently trying to find a quick solution to downloading files from Google Drive (shared files, not files I own) to a location on a server / network drive.</p>
  
  <p>I was using:</p>
  
  <pre><code>$client = new-object System.Net.WebClient
  $client.Credentials =  Get-Credential
  $client.DownloadFile("https://docs.google.com/a/domainname.co.uk/spreadsheets/d/1in0m8PhfiYhu4qCWO1dxNc3OS3p8prF7HWRZ-bjnKBI/export?format=xlsx","W:\Corp\Comp Serv\Comp Op\OB\Dep Data\Call\Google backup")
  </code></pre>
  
  <p>However it returns with the message: 
  Exception calling "DownloadFile" with "2" argument(s): "The remote server returned an error: (407) Proxy Authentication Required."</p>
  
  <p>So I added the following line between Credentials and DownloadFile:</p>
  
  <pre><code>$client.Proxy.Credentials =[System.Net.CredentialCache]::DefaultNetworkCredentials
  </code></pre>
  
  <p>This has solved the (407) Proxy Authentication Required problem, but now I'm getting the error:</p>
  
  <blockquote>
    <p>Exception calling "DownloadFile" with "2" argument(s): "An exception
    occurred during a WebClient request." </p>
    
    <p>At line:1 char:21</p>
    
    <ul>
    <li>$client.DownloadFile &lt;&lt;&lt;&lt; ("<a href="https://docs.google.com/a/domainname.co.uk/spreadsheets/d/1in0m8PhfiYhu4qCWO1dxNc3OS3p8prF7HWRZ-bjnKBI/export?format=xlsx" rel="nofollow">https://docs.google.com/a/domainname.co.uk/spreadsheets/d/1in0m8PhfiYhu4qCWO1dxNc3OS3p8prF7HWRZ-bjnKBI/export?format=xlsx</a>","W:\Corp\Comp Serv\Comp Op\OB\Dep Data\Call\Google backup")
    <ul>
    <li>CategoryInfo          : NotSpecified: (:) [], MethodInvocationException</li>
    <li>FullyQualifiedErrorId : DotNetMethodException</li>
    </ul></li>
    </ul>
  </blockquote>
  
  <p>And, because I'm pretty much a complete beginner with Powershell, I have no idea why I'm getting this message.</p>
  
  <p>Eventually, I need it to download a total of 4/5 files, all to the same location... also, ideally, I need this to run via a batch command or something equivalent so it can be a (almost) 1 Click solution...</p>
  
  <p>Any help would be greatly appreciated! Thanks~</p>