gpt4 book ai didi

powershell - 自动保存在 Powershell 中

转载 作者:行者123 更新时间:2023-12-04 18:01:50 25 4
gpt4 key购买 nike

我正在做的是运行它,它会打开网站,它是一个下载。一旦它出现,我就会收到保存它的提示。我想知道如何编写代码来自动保存这个文件?
enter image description here

 $URL = "http://ps2pw027012/Reports/Reserved.ReportViewerWebControl.axd?ReportSession=bc5nij45tlov50byl2dsxgqk&Culture=1033&CultureOverrides=False&UICulture=9&UICultureOverrides=Fal
se&ReportStack=1&ControlID=31a059a77a994ddc9f56f61d81f64615&OpType=Export&FileName=Local+Group+Members&ContentDisposition=OnlyHtmlInline&Format=CSV"
$ie = New-Object -com internetexplorer.application;
$ie.visible = $true;
$ie.Navigate($URL);
while ($ie.Busy -eq $true) { Start-Sleep -Seconds 100; } #wait for browser idle

最佳答案

您有几个选项可以执行此操作。您实际上并不需要使用浏览器对象来下载文件。这是一个关于如何使用 Powershell 下载文件的好网站,Use PowerShell to download a file with HTTP, HTTPS, and FTP

PowerShell 3 及更高版本:

Invoke-WebRequest -Uri "https://www.contoso.com/file" -OutFile "C:\path\file"

Powershell 2 有这种下载文件的方式:
$WebClient = New-Object System.Net.WebClient
$WebClient.DownloadFile("https://www.contoso.com/file","C:\path\file")

上面的链接更详细地介绍了通过不同方法下载和保存文件的各种方法。

关于powershell - 自动保存在 Powershell 中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45489230/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com