Posted On October 30, 2019

PowerShell: Detect Antivirus Name on a Windows Machine

kimconnect 0 comments
blog.KimConnect.com >> Codes >> PowerShell: Detect Antivirus Name on a Windows Machine
function getAntivirusName {  
$wmiQuery = "SELECT * FROM AntiVirusProduct"
$antivirus = Get-WmiObject -Namespace "root\SecurityCenter2" -Query $wmiQuery @psboundparameters -ErrorVariable myError -ErrorAction 'SilentlyContinue'

if($antivirus){
return $antivirus.displayName
}else{
$alternateAntivirusQuery=WMIC /Node:localhost /Namespace:\\root\SecurityCenter2 Path AntiVirusProduct GET displayName /Format:List|?{$_.trim() -ne ""}|%{$_ -replace "displayName=",""}
if ($alternateAntivirusQuery){
return $alternateAntivirusQuery
}else{
write-host "No antivirus software were detected. Hence, namespace querying errors."
$rawSearch=((get-wmiobject -class "Win32_Process" -namespace "root\cimv2" | where-object {$_.Name.ToLower() -match "antivirus|endpoint|protection|security|defender|msmpeng"}).Name | Out-String).Trim();
if($rawSearch){
return $rawSearch
}else{
return "No antivirus detected."
}
}

}
}
getAntivirusName;

Leave a Reply

Your email address will not be published. Required fields are marked *

Related Post

Centos 5.3 Server preparation for web hosting

These are compatible Repositories: FreshRPMS, Dries, NewRPMS and PlanetCCRMA   Note: to update PHP and…

PowerShell: Setting or Resetting User Password

$username='dragoncoin' $newPassword='SomeComplexPasswordHere' function resetPassword($username,$password){ if($env:userdnsdomain){ try{ Unlock-ADAccount -Identity $username Set-ADAccountPassword -Identity $username -Reset -NewPassword (ConvertTo-SecureString…

PowerShell: Disable Windows Defender

Simultaneous Uninstalls: # removeWindowsDefender.ps1 # Version 0.02 $computerNames=@( 'server1', 'server2' ) function removeWindowsDefender($computerNames){ function uninstallWindefend($computername){…