简体   繁体   English

下载使用Powershell通过https调用生成的文件

[英]Download a file which is generated through https call using powershell

Currently I have this short piece of code. 目前,我有这段简短的代码。 The URL https://dosomething.do generates a .csv file. URL https://dosomething.do生成一个.csv文件。 I can run the powershell code and in the shell I can see the content of the file. 我可以运行powershell代码,并在shell中可以看到文件的内容。 However the file itself is not downloaded. 但是,文件本身未下载。 I would like to specify where to save it after a download. 我想指定下载后的保存位置。 What are my options here? 我在这里有什么选择?

$securepassword = ConvertTo-SecureString "xxx" -AsPlainText -Force
$credentials = New-Object System.Management.Automation.PSCredential("hxxx", $securepassword)
Invoke-WebRequest -Uri "https://dosomething.do" -Credential $credentials

使用Invoke-WebRequest-OutFile参数:

Invoke-WebRequest -Uri "https://dosomething.do" -OutFile C:\some\path\to\yourfile.csv

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM