Downloading a file with Powershell

后端 未结 1 825
北荒
北荒 2020-12-14 06:44

The following Google Doc gets exported to CSV and is then downloaded automatically using a standard Web Browser: https://docs.google.com/spreadsheets/d/1wDD_Xm8IQYuYNefv9cOJ

相关标签:
1条回答
  • 2020-12-14 07:10

    Invoke-WebRequest comes with a parameter to store its result in a file: -OutFile

    Invoke-WebRequest URL -OutFile c:\file.ext
    

    If you need authorization before you can send a request like this:

    Invoke-WebRequest URL /* whatever is neccesary to login */ -SessionVariable MySession
    Invoke-WebRequest URL -WebSession $MySession
    

    To determine the layout of the form where the login happens, you can use Invoke-WebRequests return object. It'll collect information about forms and fields on the HTML (might be Windows only). Mileage of logging in may vary with things like Two-Factor-Auth active or not. Probably you can create some secret link to your file which does not need Auth or possibly google allows you to create a private access token of some sort, which can be send aus Authorization-Header alongside your request.

    0 讨论(0)
提交回复
热议问题