全部。Powershell:查找已安裝的防病毒軟件,過濾掉Windows Defender
我有一個PowerShell腳本,它將檢測安裝在Windows中的防病毒軟件(它實際上很常見)。問題是,我想要它過濾Windows Defender,尤其是在Windows 8,8.1和10自帶安裝的情況下。我希望我的腳本能夠指示Windows Defender是否僅顯示防病毒軟件,如果是,則顯示不同的輸出。
這裏是我迄今爲止...
function Get-AntivirusName {
[cmdletBinding()]
param (
[string]$ComputerName = "$env:computername" ,
$Credential
)
BEGIN
{
$wmiQuery = "SELECT * FROM AntiVirusProduct"
}
PROCESS
{
$AntivirusProduct = Get-WmiObject -Namespace "root\SecurityCenter2" -Query $wmiQuery @psboundparameters
$AntivirusNames = $AntivirusProduct.displayName
if ($AntivirusNames -eq "") {
Write-host "Anti-Virus is NOT installed!"
}
elseif ($AntivirusNames -eq "Windows Defender") {
Write-host "ONLY Windows Defender is installed!"
}
else {
Write-host "Anti-Virus is installed (" + $AntivirusNames + ")."
}
}
END {
}
}
Get-AntivirusName
結果是,不管所安裝的其他殺毒軟件的應用程序,它不斷告訴我只安裝了Windows Defender的。有人能指出我錯過了什麼嗎?
非常感謝!