根据系统信息调用 Web 请求



好的,所以我想要的是一个基于给定系统信息使用调用 web 请求命令的脚本。 因此,假设我有两个不同的安装程序,一个用于 Nvidia GPU 系统,另一个用于 AMD GPU 系统,我已经可以使用另一个脚本获取 GPU 信息,并将其保存到 html 链接或文本文件中,但是我如何使用这些信息,使用 invoke Web 请求,下载正确的安装程序?

这是我用来获取 GPU 信息的 VB 脚本:

strComputer = "."
Set objWMIService = GetObject("winmgmts:\" & strComputer &"rootCIMV2") 
Set colItems = objWMIService.ExecQuery( _ "SELECT *FROM Win32_VideoController",,48) 
For Each objItem in colItems
Wscript.Echo "-----------------------------------" 
Wscript.Echo "Win32_VideoController instance" 
Wscript.Echo "-----------------------------------" 
Wscript.Echo"Caption:"&objItem.Caption 
Next

你不需要混合搭配VBS和PowerShell,PowerShell完全能够自行查询WMI!

使用Where-Object根据Caption值筛选结果,然后使用if语句确定是否找到每种类型中的任何一种:

$allVideoControllers = Get-CimInstance -Class Win32_VideoController
if($allVideoControllers |Where-Object Caption -like '*NVidia*'){
# Found an nvdia card, download and run the nvidia installer in here
}
if($allVideoControllers |Where-Object Caption -like '*AMD*'){
# Found an AMD card, download and run the AMD installer in here
}

最新更新