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

标签 powershell powershell-5.0 web-administration

目前我有这段简短的代码。 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/

相关文章:

Powershell 2 和 .NET : Optimize for extremely large hash tables?

powershell - 列出重定向目标 (URL) IIS 站点

powershell - 使用 passthru 确保 cmdlet 完成

powershell - v5特殊方法 `New`与静态方法 `New`冲突

Powershell获取当前域名或计算机名\用户以及两者之间的区别

powershell - DSC 配置不断重启

c# - 通过代码(C# 或 PowerShell)获取有关进程(如 Sysinternals Process Explorer)的 .NET 程序集信息

powershell - about_Foreach 示例 : cmd subroutine syntax in PowerShell?

powershell - 如何在 PowerShell v5 模块中导出类