title: DL CSV from Google sheets using PowerShell
body: <ol>
  <li>I have a Google sheet where I have published a CSV to the web.</li>
  <li>I am trying to use PowerShell to download the CSV.</li>
  <li>After the CSV downloads I log the event in a the log file with datestamp.</li>
  <li>I use Windows Task Scheduler to do this daily.</li>
  </ol>
  
  <p>I have tried to use the code below, and it seems to work if I copy/paste it into PowerShell, but when I double-click to run it, I get errors.</p>
  
  <pre><code>$client = New-Object System.Net.WebClient
  $client.DownloadFile(“https://docs.google.com/spreadsheets/d/e/2xxxxxxxxxxxxxxxxxxxxxxxx/pub?gid=xxxx&amp;single=true&amp;output=csv”,“C:\Users\xxxxxxxxxx\sent_ordes.txt")
  
  function Get-TimeStamp {
      return "[{0:MM/dd/yy} {0:HH:mm:ss}]" -f (Get-Date)
  }
  
  Write-Output "$(Get-TimeStamp) Sent Orders Powershell run " | Out-File 
  C:\Users\xxxxxxxxxxxxxx\Sent_Orders.log -Append
  </code></pre>