首页 > 解决方案 > 根据系统信息调用 Web 请求

问题描述

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

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

strComputer = "."
  Set objWMIService = GetObject("winmgmts:\\" & strComputer &"\root\CIMV2") 
    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

标签: windowspowershellvbscript

解决方案


您不需要混合搭配 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
}

推荐阅读