目前我有这段简短的代码。 URL https://dosomething.do
生成一个 .csv 文件。我可以运行 powershell 代码,并在 shell 中看到文件的内容。但是文件本身并没有被下载。我想指定下载后的保存位置。我在这里有什么选择?
$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
关于powershell - 使用powershell下载通过https调用生成的文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48902844/