-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathAvStatusFetcher.ps1
39 lines (39 loc) · 1.72 KB
/
AvStatusFetcher.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
<#
Av Status Fetcher
Attention: As long as the Defender is not primary software, regardless it is in passive mode or PxP mode. it will all show disabled.
By Tom.Ding
#>
Function Get-AvStatusFetcher {
$AvStatus=(Get-CimInstance -Namespace root/SecurityCenter2 -ClassName AntiVirusProduct | Select-Object productState | ForEach-Object { [System.String]::Format('{0:X}', $_.productState)});$AvName=Get-CimInstance -Namespace root/SecurityCenter2 -ClassName AntiVirusProduct | Select-Object displayName ;$counter=-1;$seq=0
$AvStatus | ForEach-Object {
$counter=$counter+1
$seq=$seq+1
$AVnum=$AVnum
$CompareVar = [string]$_
if ($CompareVar[-2] -eq "1" -and $CompareVar[-4] -eq "0" )
{
Write-Host $seq " : " $AvName[$counter].displayName "is out of date and disabled."
$AVnum=$AVnum+1
}
elseif ($CompareVar[-2] -eq "0" -and $CompareVar[-4] -eq "1" )
{
Write-Host $seq " : " $AvName[$counter].displayName "is up to date and enabled."
$AVnum=$AVnum+1
}
elseif ($CompareVar[-2] -eq "1" -and $CompareVar[-4] -eq "1")
{
Write-Host $seq " : " $AvName[$counter].displayName "is out of date and enabled."
$AVnum=$AVnum+1
}
elseif ($CompareVar[-2] -eq "0" -and $CompareVar[-4] -eq "0")
{
Write-Host $seq " : " $AvName[$counter].displayName "is up to date but disabled."
$AVnum=$AVnum+1
}
else {
Write-Host $seq " : " $AvName[$counter].displayName "didn't find any matched or installed before but currently not exist in system"
}
}
Write-Host "Total $AVnum AV installed on this system."
}
Get-AvStatusFetcher