全部。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的。有人能指出我错过了什么吗?
非常感谢!