根据系统信息调用web请求
Invoke web request based on system information
好的,我想要的是一个脚本,它使用基于给定系统信息的调用网络请求命令。
所以假设我有两个不同的安装程序,一个用于 Nvidia gpu 系统,另一个用于 AMD gpu 系统,我已经可以使用另一个脚本获取 gpu 信息,并将其保存到 html link 或文本文件,但我如何使用此信息,使用调用 Web 请求,来下载正确的安装程序?
这是我用来获取 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
您不需要混合搭配 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
}
好的,我想要的是一个脚本,它使用基于给定系统信息的调用网络请求命令。 所以假设我有两个不同的安装程序,一个用于 Nvidia gpu 系统,另一个用于 AMD gpu 系统,我已经可以使用另一个脚本获取 gpu 信息,并将其保存到 html link 或文本文件,但我如何使用此信息,使用调用 Web 请求,来下载正确的安装程序?
这是我用来获取 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
您不需要混合搭配 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
}