运行时弹出IE powershell脚本

IE pop up when running powershell script

有我想要的脚本 运行 我们的一台服务器有一个查询用户:

#HTML
$Wcl = new-object System.Net.WebClient
$Wcl.Headers.Add(“xxxx”, $xxxxxx)
$Wcl.Proxy.Credentials = [System.Net.CredentialCache]::DefaultNetworkCredentials
$html = Invoke-WebRequest -Uri https://www.mcafee.com/enterprise/en-us/downloads/security-updates.html
$dathtml = ($html.parsedhtml.getelementsbytagname("TR") |% { ( $_.children | ?{ $_.tagName -eq "td"} | % innerText ) } | Select-Object -First 1).Split('xdat')[0] 

我明白了 window:

TrustedZone

我已经将此站点添加到受信任的区域,但总是得到这个 window,我选择关闭并正确选择脚本 运行ning。

如何在电源 shell 中关闭此弹出窗口?

感谢您的帮助。

Invoke-WebRequest 将默认尝试使用 Internet Explorer。但是,如果您使用开关进行基本解析 -UseBasicParsing,您应该能够解决这个问题,这样您就不会使用资源管理器,因此不会 运行 进入 Microsoft 的 "Trusted Zones" 要求:

-UseBasicParsing Indicates that the cmdlet uses the response object for HTML content without Document Object Model (DOM) parsing.

This parameter is required when Internet Explorer is not installed on the computers, such as on a Server Core installation of a Windows Server operating system.

尝试将您的调用设置为:

$html = Invoke-WebRequest -Uri https://www.mcafee.com/enterprise/en-us/downloads/security-updates.html -UseBasicParsing