Windows云服务器列出Tencent和Red Hat驱动
以下代码是我在Server2008R2-2022和Win10、Win11上调试过的,大有用处
代码语言:powershell复制#列出腾讯的驱动
$TencentDrivers = pnputil.exe -e | Select-String -Pattern "Tencent" -Context 1, 0
$OEMNumbers = $TencentDrivers.Context.PreContext | Select-String -Pattern "oemd .inf" -AllMatches | % { $_.Matches } | % { $_.Value }
$drivers = pnputil /enum-drivers
$driverLines = $drivers -split "`r`n"
$found = $false
foreach ($line in $driverLines) {
$currentOem = ""
if ($line -match "Published Name") {
$currentOem = ($line -split ":")[-1].Trim()
}
if ($OEMNumbers -contains $currentOem) {
$found = $true
} elseif ($line.StartsWith("Published Name")) {
$found = $false
}
if ($found) {
Write-Host $line
}
}
#列出红帽的驱动
$RedhatDrivers = pnputil.exe -e | Select-String -Pattern "Red Hat" -Context 1, 0
$OEMNumbers = $RedhatDrivers.Context.PreContext | Select-String -Pattern "oemd .inf" -AllMatches | % { $_.Matches } | % { $_.Value }
$drivers = pnputil /enum-drivers
$driverLines = $drivers -split "`r`n"
$found = $false
foreach ($line in $driverLines) {
$currentOem = ""
if ($line -match "Published Name") {
$currentOem = ($line -split ":")[-1].Trim()
}
if ($OEMNumbers -contains $currentOem) {
$found = $true
} elseif ($line.StartsWith("Published Name")) {
$found = $false
}
if ($found) {
Write-Host $line
}
}