|
19 | 19 |
|
20 | 20 | .NOTES |
21 | 21 | Version 1.0 4/7/2021 silversword |
22 | | - https://mcpforlife.com/2020/04/14/how-to-resolve-this-state-value-of-av-providers/ |
23 | | - https://github.com/wortell/PSHelpers/blob/main/src/Public/Add-ProductStates.ps1 |
24 | | - Call with optional parameter "-antivirusName AntivirusNameHere" in order to check for a specific antivirus |
25 | | - antivirusName must match the "displayName" exactly |
26 | | - If no antivirusName parameter is specified, the tool returns success if there is any active up to date antivirus on the system |
| 22 | + https://mcpforlife.com/2020/04/14/how-to-resolve-this-state-value-of-av-providers/ |
| 23 | + https://github.com/wortell/PSHelpers/blob/main/src/Public/Add-ProductStates.ps1 |
| 24 | + Call with optional parameter "-antivirusName AntivirusNameHere" in order to check for a specific antivirus |
| 25 | + antivirusName must match the "displayName" exactly |
| 26 | + If no antivirusName parameter is specified, the tool returns success if there is any active up to date antivirus on the system |
27 | 27 | Version 1.1 10/15/2023 dinger1986 |
28 | | - Added in -customfield to write AV name to a customfield |
| 28 | + Added in -customfield to write AV name to a customfield |
29 | 29 |
|
30 | | - OS Build must be greater than 14393 to support this script. If it's not it returns exit code 2 |
| 30 | + OS Build must be greater than 14393 to support this script. If it's not it returns exit code 2 |
| 31 | + Version 1.2 7/31/2025 silversword Removing extra text in -customField mode |
31 | 32 | #> |
32 | 33 |
|
33 | 34 | param($antivirusName = "*", [switch]$customField) |
@@ -58,7 +59,7 @@ param($antivirusName = "*", [switch]$customField) |
58 | 59 | function Add-ProductStates { |
59 | 60 | [CmdletBinding()] |
60 | 61 | param ( |
61 | | - # This parameter can be passed from pipeline and can contain and array of collections that contain State or productstate members |
| 62 | + # This parameter can be passed from pipeline and can contain and array of collections that contain State or productstate members |
62 | 63 | [Parameter(ValueFromPipeline)] |
63 | 64 | [Microsoft.Management.Infrastructure.CimInstance[]] |
64 | 65 | $Products, |
@@ -120,18 +121,19 @@ if ([environment]::OSVersion.Version.Build -le 14393) { |
120 | 121 |
|
121 | 122 | $return = Get-CimInstance -Namespace root/SecurityCenter2 -className AntivirusProduct | |
122 | 123 | Where-Object { |
123 | | - ($_.displayName -like $antivirusName) -and |
124 | | - (($_.productState -band [ProductFlags]::ProductState) -eq [ProductState]::On) -and |
125 | | - (($_.productState -band [ProductFlags]::SignatureStatus) -eq [SignatureStatus]::UpToDate) |
| 124 | + ($_.displayName -like $antivirusName) -and |
| 125 | + (($_.productState -band [ProductFlags]::ProductState) -eq [ProductState]::On) -and |
| 126 | + (($_.productState -band [ProductFlags]::SignatureStatus) -eq [SignatureStatus]::UpToDate) |
126 | 127 | } |
127 | 128 |
|
128 | | -Write-Host "Antivirus selection: $antivirusName" |
129 | 129 | if ($return) { |
130 | 130 | if ($customField) { |
131 | 131 | # Only output the name of the first antivirus |
132 | 132 | $return[0].displayName |
133 | 133 | exit 0 |
134 | | - } else { |
| 134 | + } |
| 135 | + else { |
| 136 | + Write-Host "Antivirus selection: $antivirusName" |
135 | 137 | Write-Host "Antivirus active and up to date" |
136 | 138 | $return |
137 | 139 | } |
|
0 commit comments