Get-AntiVirusState - Connaître l'état des antivirus d'un parc

CréationNicolas THOREZ 2019/02/19 19:58

Connaître l'état de protection de l'ensemble des PC dans un domaine est très important pour un administrateur afin de garantir la sécurité d'un parc informatique. Dans le cas où les antivirus sont gérés de manière centralisée par un logiciel tel que Kaspersky Security Center, cela est assez facile. Dans les cas où on n'a pas ce genre d'outil, cela devient légèrement plus compliqué. On pourrait faire régulièrement le tour de chaque poste mais cela coûte énormément en temps et en moyen surtout si la structure est imposante. Partons donc sur le principe que "Un administrateur qui n'a pas recours à des scripts est condamné à refaire sans cesse les mêmes choses".

Le script suivant s'inscrit dans cette optique. Il interroge les PC du domaine afin de connaître l'antivirus qui y est installé, l'état de ses mises à jour ainsi que le statut de sa protection en temps réel.

Comme souvent, j'y rajoute une sortie sous forme de rapport afin de traiter ce dernier avec une vérification Nagios.

<#
.SYNOPSIS


    ███████╗██╗  ██╗██╗   ██╗██████╗ ██╗  ██╗ █████╗                 
    ██╔════╝██║  ██║╚██╗ ██╔╝██╔══██╗██║ ██╔╝██╔══██╗                
    ███████╗███████║ ╚████╔╝ ██████╔╝█████╔╝ ███████║                
    ╚════██║██╔══██║  ╚██╔╝  ██╔══██╗██╔═██╗ ██╔══██║                
    ███████║██║  ██║   ██║   ██║  ██║██║  ██╗██║  ██║                
    ╚══════╝╚═╝  ╚═╝   ╚═╝   ╚═╝  ╚═╝╚═╝  ╚═╝╚═╝  ╚═╝                
                                                                 
                ███████╗██╗   ██╗███████╗████████╗███████╗███╗   ███╗
                ██╔════╝╚██╗ ██╔╝██╔════╝╚══██╔══╝██╔════╝████╗ ████║
                ███████╗ ╚████╔╝ ███████╗   ██║   █████╗  ██╔████╔██║
                ╚════██║  ╚██╔╝  ╚════██║   ██║   ██╔══╝  ██║╚██╔╝██║
                ███████║   ██║   ███████║   ██║   ███████╗██║ ╚═╝ ██║
                ╚══════╝   ╚═╝   ╚══════╝   ╚═╝   ╚══════╝╚═╝     ╚═╝
                                                                 


#############################################################################################################
#                                                                                                           #
# Script de récupération de l'état des antivirus des postes                                                 #
#                                                                                                           #
# Par Nicolas THOREZ                                                                                        #
#                                                                                                           #
#############################################################################################################

.DESCRIPTION

Ce script permet d'interroger à distance un et plusieurs PC du domaine afin de connaître le nom de son antivirus et son état.

.PARAMETER PC

Indique le ou les noms (séparé par des virgules (,)) des PC à interroger. Si le paramètre n'est pas renseigner, la requête sera lancée sur tous les PC contenus dans les OU PC Fixes, PC Portables et Direction.

.PARAMETER Nagios

Si le paramètre -Nagios est indiqué, un fichier de réponse pour un traitement par Nagios sera créé (C:\Scripts\AntivirusState\Report.dat)

.PARAMETER Verbose

Si ce paramètre est indiqué, la console affichera les informations sur le déroulement du script.

.EXAMPLE

Get-AVState.ps1 -PC PC-7,PC-49 -Nagios -Verbose

Lance la requête d'interrogation de l'état des antivirus des PC PC-7 et PC-49. A la fin, un rapport pour Nagios sera créer.

Affichage dans la console : 
2019-02-13 16:25:06     INFO     Création du fichier log.
2019-02-13 16:25:06     INFO     Suppression des logs vieux de 7 jours.
2019-02-13 16:25:06     INFO     Début de la vérification des antivirus.
2019-02-13 16:25:06     INFO     Début de traitement de PC-7.
2019-02-13 16:25:06     INFO     PC Online.
2019-02-13 16:25:06     INFO     Antivirus détecté : Avast Antivirus.
2019-02-13 16:25:06     INFO     Fournisseur d'informations : Antivirus.
2019-02-13 16:25:06     INFO     Protection en temps réel active.
2019-02-13 16:25:06     INFO     Bases de définitions de virus à jour.
2019-02-13 16:25:06     INFO     Début de traitement de PC-49.
2019-02-13 16:25:07     INFO     PC Online.
2019-02-13 16:25:07     INFO     Antivirus détecté : Kaspersky Free.
2019-02-13 16:25:07     INFO     Fournisseur d'informations : Antivirus.
2019-02-13 16:25:07     INFO     Protection en temps réel active.
2019-02-13 16:25:07     INFO     Bases de définitions de virus à jour.
----------------------------------------------------------
2019-02-13 16:25:07     INFO     Total des PC : 2.
2019-02-13 16:25:07     INFO     PC interrogés : 0.
2019-02-13 16:25:07     INFO     PC hors-ligne : 0.
2019-02-13 16:25:07     INFO     Aucun avertissement détecté.
2019-02-13 16:25:07     INFO     Aucun critique détecté.
2019-02-13 16:25:07     INFO     Création du rapport pour Nagios.

.NOTES

NOM :      Get-AntiVirusState.ps1
AUTEUR :   Nicolas THOREZ
VERSION :  1.3

HISTORIQUE :

0.0     2019-02-12      Début du projet

0.1     2019-02-13      Etude du routine existante
                        Création du script

1.0     2019-02-13      Version mis en production

1.1     2019-02-13      Ajout de la création du rapport pour Nagios

1.1.1   2019-02-14      Correction d'erreurs dans le rapport Nagios

1.2     2019-03-26      Modification du mode verbeux

1.3     2019-04-08      Optimisation du code

#>

# Paramètres d'entrée

Param(
    [String[]]$PC="All",
    [Switch]$Nagios,
    [Switch]$Verbose
)

# Déclaration des variables

If ($PC -eq "All")
    {
        $ListPC = (Get-ADComputer -SearchBase "OU=PC Fixe,OU=Ordinateurs,DC=TEST,DC=LOCAL" -Filter *).Name
        $ListPC += (Get-ADComputer -SearchBase "OU=PC Portable,OU=Ordinateurs,DC=TEST,DC=LOCAL" -Filter *).Name
        $ListPC += (Get-ADComputer -SearchBase "OU=Ordinateurs,OU=Direction,DC=TEST,DC=LOCAL" -Filter *).Name
    }
Else
    {
        $ListPC = $PC
    }
$CheckDate = Get-Date -UFormat %Y-%m-%d
$Path = "C:\Scripts\AntivirusState"
$LogFile = "$Path\AntivirusState-$CheckDate.log"
$ScriptName = "Get-AntiVirusState.ps1"
$Old = 7
$TotalPC = 0
$PCOnline = 0
$PCOffline = 0
$CritCount = 0
$WarnCount = 0
$Result = @()
$PCWithManyAV = "n/a"
$PCWithoutAV = "n/a"
$PCWithFaultyRT = "n/a"
$PCWithObsoleteBase = "n/a"
$Domaine = "TEST"
$FQDN = "test.local"
$Report = "$Path\Report.dat"


# Déclacation des fonctions
Function Add-Log()
    {
        Param
            (
                [string]$Type,
                [string]$Message,
                [switch]$Line
            )

        If ($Line)
            {
                Write-Host "----------------------------------------------------------------------"
                Add-Content -Path $LogFile -Value "----------------------------------------------------------------------"
            }
        Else
            {
                $CheckTime = Get-Date -Format G
                If ($Verbose)
                    {
                        Switch($Type)
                            {
                                "INFO"
                                    {
                                        $Color = "green"
                                    }
                                "WARN"
                                    {
                                        $Color = "yellow"
                                    }
                                "CRIT"
                                    {
                                        $Color = "red"
                                    }
                                "UNKN"
                                    {
                                        $Color = "magenta"
                                    }
                                default
                                    {
                                        $Color = "cyan"
                                    }
                            }
                        Write-Host "$CheckTime     " -NoNewline
                        Write-Host "$type     " -NoNewline -ForegroundColor $Color
                        Write-Host $Message
                    }
                Add-Content -Path $LogFile -Value "$CheckTime     $Type     $Message"
            }
    }

Function Get-PCOnlineStatus($PC)
    {
        # On interroge le PC via Get-WmiObject plutôt que par ping pour éviter les erreurs de pare-feu
        $OnlineTest = (Get-WmiObject -ComputerName $PC -Class Win32_ComputerSystem -ErrorAction SilentlyContinue -WarningAction SilentlyContinue -InformationAction SilentlyContinue).Domain
        If ($OnlineTest -eq $FQDN)
            {
                Add-Log -Type "INFO" -Message "PC Online."
                Return $true
            }
        Else
            {
                Add-Log -Type "WARN" -Message "PC Offline."
                Return $false
            }
    }


# Création du fichier log et suppression des anciens logs
If (Test-Path $LogFile)
    {
        Add-Log -Line
        Add-Log -Type "INFO" -Message "Fichier log existant, inscription des nouvelles informations à la suite."
        Add-Log -Type "INFO" -Message "Début de la vérification des antivirus."
        Add-Log -Line
    }
Else
    {
        New-Item -Path $LogFile > $null
        Add-Log -Type "INFO" -Message "Création du fichier log."
        Get-ChildItem –Path $Path –Recurse | Where-Object CreationTime –lt (Get-Date).AddDays(-$Old) | Where-Object Name -ne $ScriptName | Remove-Item -Force > $null
        Add-Log -Type "INFO" -Message "Suppression des logs vieux de $Old jours."
        Add-Log -Type "INFO" -Message "Début de la vérification des antivirus."
        Add-Log -Line
    }

# Traitement
ForEach($PC in $ListPC)
    {
        $TotalPC += 1
        Add-Log -Type "INFO" -Message "Début de traitement de $PC."

        
        # On teste si la machine est en ligne
        $OnlineStatus = Get-PCOnlineStatus($PC)

        # Si oui on continue le traitement
        If ($OnlineStatus -eq $true)
            {
                $PCOnline += 1
                #On vérifie le nombre d'antivirus
                $AntiVirusProduct = Get-WmiObject -Namespace "root\SecurityCenter2" -Class AntiVirusProduct  -ComputerName $PC
                $AntiVirusCount = $AntiVirusProduct.Count

                If ($AntiVirusCount.Count -gt 2)
                    {
                        # Erreur plus de 2 antivirus présents
                        Add-Log -Type "CRIT" -Message "$PC possède plusieurs antivirus. Veuillez vérifier."
                        $CritCount += 1
                        If ($PCWithManyAV -eq "n/a")
                            {
                                $PCWithManyAV = "$PC"
                            }
                        Else
                            {
                                $PCWithManyAV += ", $PC"
                            }
                        Continue
                    }
                Elseif ($AntiVirusCount -eq 2)
                    {
                        # Filtre pour supprimer Windows Defender qui doit être désactivé et création de la liste d'état de l'antivirus présent
                        $AntiVirusProduct = Get-WmiObject -Namespace "root\SecurityCenter2" -Class AntiVirusProduct -ComputerName $PC | Where-Object {$_.displayname -ne "Windows Defender"}
                    }
                If ($AntiVirusProduct -eq '')
                    {
                        #TODO Erreur pas d'antivirus
                        Add-Log -Type "CRIT" -Message "$PC ne possède aucun antivirus. Veuillez vérifier."
                        $CritCount += 1
                        If ($PCWithoutAV -eq "n/a")
                            {
                                $PCWithoutAV = "$PC"
                            }
                        Else
                            {
                                $PCWithoutAV += ", $PC"
                            }
                        Continue
                    }

                # Affichage de l'antivirus détecté
                $AVName = $AntiVirusProduct.displayName
                Add-Log -Type "INFO" -Message "Antivirus détecté : $AVName."

                # Extraction des données de l'antivirus 
                $productState = $AntiVirusProduct.productState 
 
                # Conversion en hexadecimal (avec ajout de 0 si nécessaire pour avoir une chaîne de 6 caractères) 
                $Hexa = [Convert]::ToString($productState, 16).PadLeft(6,"0") 

                # Séparation des indicateurs (les 2 premiers caractères puis les 2 suivants et enfin les 2 derniers)
                $WSC_SECURITY_PROVIDER = $Hexa.Substring(0,2) 
                $WSC_SECURITY_PRODUCT_STATE = $Hexa.Substring(2,2) 
                $WSC_SECURITY_SIGNATURE_STATUS = $Hexa.Substring(4,2)

                # Création de la valeur correspondant au type de protection
                $Provider = ''
                While ($WSC_SECURITY_PROVIDER)
                    {
                        If ([Int]$WSC_SECURITY_PROVIDER -ge 64)
                            {
                                [Int]$WSC_SECURITY_PROVIDER = [Int]$WSC_SECURITY_PROVIDER - 64
                                $Provider += "Service"
                                Add-Log -Type "INFO" -Message "Fournisseur d'informations : Service."
                            }
                        ElseIf ([Int]$WSC_SECURITY_PROVIDER -ge 32)
                            {
                                [Int]$WSC_SECURITY_PROVIDER = [Int]$WSC_SECURITY_PROVIDER - 32
                                If ($Provider -eq '')
                                    {
                                        $Provider += "User Controlled"
                                    }
                                Else
                                    {
                                        $Provider += ", User Controlled"
                                    }
                                Add-Log -Type "INFO" -Message "Fournisseur d'informations : User Controlled."
                            }
                        ElseIf ([Int]$WSC_SECURITY_PROVIDER -ge 16)
                            {
                                [Int]$WSC_SECURITY_PROVIDER = [Int]$WSC_SECURITY_PROVIDER - 16
                                If ($Provider -eq '')
                                    {
                                        $Provider += "Internet Settings"
                                    }
                                Else
                                    {
                                        $Provider += ", Internet Settings"
                                    }
                                Add-Log -Type "INFO" -Message "Fournisseur d'informations : Internet Settings."
                            }
                        ElseIf ([Int]$WSC_SECURITY_PROVIDER -ge 8)
                            {
                                [Int]$WSC_SECURITY_PROVIDER = [Int]$WSC_SECURITY_PROVIDER - 8
                                If ($Provider -eq '')
                                    {
                                        $Provider += "AntiSpyware"
                                    }
                                Else
                                    {
                                        $Provider += ", AntiSpyware"
                                    }
                                Add-Log -Type "INFO" -Message "Fournisseur d'informations : AntiSpyware."
                            }
                        ElseIf ([Int]$WSC_SECURITY_PROVIDER -ge 4)
                            {
                                [Int]$WSC_SECURITY_PROVIDER = [Int]$WSC_SECURITY_PROVIDER - 4
                                If ($Provider -eq '')
                                    {
                                        $Provider += "Antivirus"
                                    }
                                Else
                                    {
                                        $Provider += ", Antivirus"
                                    }
                                Add-Log -Type "INFO" -Message "Fournisseur d'informations : Antivirus."
                            }
                        ElseIf ([Int]$WSC_SECURITY_PROVIDER -ge 2)
                            {
                                [Int]$WSC_SECURITY_PROVIDER = [Int]$WSC_SECURITY_PROVIDER - 2
                                If ($Provider -eq '')
                                    {
                                        $Provider += "AutoUpdate"
                                    }
                                Else
                                    {
                                        $Provider += ", AutoUpdate"
                                    }
                                Add-Log -Type "INFO" -Message "Fournisseur d'informations : AutoUpdate."
                            }
                        ElseIf ([Int]$WSC_SECURITY_PROVIDER -ge 1)
                            {
                                [Int]$WSC_SECURITY_PROVIDER = [Int]$WSC_SECURITY_PROVIDER - 1
                                If ($Provider -eq '')
                                    {
                                        $Provider += "FireWall"
                                    }
                                Else
                                    {
                                        $Provider += ", FireWall"
                                    }
                                Add-Log -Type "INFO" -Message "Fournisseur d'informations : FireWall."
                            }
                    }
                If ($Provider -eq '')
                    {
                        $Provider = "None"
                        Add-Log -Type "WARN" -Message "Aucun fournisseurs d'informations, veuillez vérifier l'état de l'antivirus."
                    }

                # Création de la valeur correspondant au status de la protection en temps réel
                Switch ($WSC_SECURITY_PRODUCT_STATE)
                    {
                        "00"
                            {
                                $RTStatus = "Inactif"
                                Add-Log -Type "CRIT" -Message "Protection en temps réel inactive, veuillez vérifier l'état de l'antivirus."
                                $CritCount += 1
                                If ($PCWithFaultyRT -eq "n/a")
                                    {
                                        $PCWithFaultyRT = "$PC"
                                    }
                                Else
                                    {
                                        $PCWithFaultyRT += ", $PC"
                                    }
                            }
                        "01"
                            {
                                $RTStatus = "En arrêt"
                                Add-Log -Type "WARN" -Message "Protection en temps réel en cours d'arrêt, veuillez vérifier l'état de l'antivirus."
                                $WarnCount += 1
                                If ($PCWithFaultyRT -eq "n/a")
                                    {
                                        $PCWithFaultyRT = "$PC"
                                    }
                                Else
                                    {
                                        $PCWithFaultyRT += ", $PC"
                                    }

                            }
                        "10"
                            {
                                $RTStatus = "Actif"
                                Add-Log -Type "INFO" -Message "Protection en temps réel active."
                            }
                        "11"
                            {
                                $RTStatus = "En veille"
                                Add-Log -Type "INFO" -Message "Protection en temps réel en état de veille."
                            }
                        default
                            {
                                $RTStatus = "Inconnu"
                                Add-Log -Type "UNKN" -Message "Etat de la protection en temps réel inconnu, veuillez vérifier l'état de l'antivirus."
                                $WarnCount += 1
                                If ($PCWithFaultyRT -eq "n/a")
                                    {
                                        $PCWithFaultyRT = "$PC"
                                    }
                                Else
                                    {
                                        $PCWithFaultyRT += ", $PC"
                                    }

                            }
                    }

                # Création de la valeur correspondant au niveau de la définitions de virus
                Switch ($WSC_SECURITY_SIGNATURE_STATUS)
                    {
                        "00"
                            {
                                Add-Log -Type "INFO" -Message "Bases de définitions de virus à jour."
                            }
                        "10"
                            {
                                Add-Log -Type "WARN" -Message "Bases de définitions de virus obsolètes."
                                $WarmCount += 1
                                If ($PCWithObsoleteBase -eq "n/a")
                                    {
                                        $PCWithObsoleteBase = "$PC"
                                    }
                                Else
                                    {
                                        $PCWithObsoleteBase += ", $PC"
                                    }
                            }
                        default
                            {
                                Add-Log -Type "UNKN" -Message "Impossible de déterminer l'état des bases, veuillez vérifier l'état de l'antivirus."
                                $WarnCount += 1
                                If ($PCWithObsoleteBase -eq "n/a")
                                    {
                                        $PCWithObsoleteBase = "$PC"
                                    }
                                Else
                                    {
                                        $PCWithObsoleteBase += ", $PC"
                                    }
                            }
                    }
            }
        Else
            {
                $PCOffline += 1
            }
    }

# Affichage du résumé
Add-Log -Line
Add-Log -Type "INFO" -Message "Total des PC : $TotalPC."
Add-Log -Type "INFO" -Message "PC interrogés : $PCOnline."
If ($PCOffline)
    {
        Add-Log -Type "WARN" -Message "PC hors-ligne : $PCOffline."
    }
Else
    {
        Add-Log -Type "INFO" -Message "PC hors-ligne : $PCOffline."
    }
If ($WarnCount)
    {
        Add-Log -Type "WARN" -Message "Avertissement : $WarnCount."
    }
Else
    {
        Add-Log -Type "INFO" -Message "Avertissement : $WarnCount."
    }
If ($CritCount)
    {
        Add-Log -Type "CRIT" -Message "Critique : $CritCount."
    }
Else
    {
        Add-Log -Type "INFO" -Message "Critique : $CritCount."
    }
If ($PCWithObsoleteBase -ne "n/a")
    {
        Add-Log -Type "WARN" -Message "PC nécessitant une mise à jour des bases de définitions de virus : $PCWithObsoleteBase."
    }
Else
    {
        Add-Log -Type "INFO" -Message "PC nécessitant une mise à jour des bases de définitions de virus : $PCWithObsoleteBase."
    }

If ($PCWithFaultyRT -ne "n/a")
    {
        Add-Log -Type "CRIT" -Message "PC n'ayant pas la protection en temps réel activée : $PCWithFaultyRT."
    }
Else
    {
        Add-Log -Type "INFO" -Message "PC n'ayant pas la protection en temps réel activée : $PCWithFaultyRT."
    }
If ($PCWithManyAV -ne "n/a")
    {
        Add-Log -Type "CRIT" -Message "PC ayant plusieurs antivirus actifs : $PCWithManyAV."
    }
Else
    {
        Add-Log -Type "INFO" -Message "PC ayant plusieurs antivirus actifs : $PCWithManyAV."
    }
If ($PCWithoutAV -ne "n/a")
    {
        Add-Log -Type "CRIT" -Message "PC n'ayant aucun antivirus actif : $PCWithoutAV."
    }
Else
    {
        Add-Log -Type "INFO" -Message "PC n'ayant aucun antivirus actif : $PCWithoutAV."
    }


# Création du rapport pour Nagios
If ($Nagios)
    {
        # On supprime l'ancien rapport
        If (Test-Path $Report)
            {
                Remove-Item -Path $Report -Force > $null
            }

        # Affichage dans la console
        Add-Log -Line
        Add-Log -Type "INFO" -Message "Création du rapport pour Nagios."

        # On crée un rapport vide
        $TempVar = @{}
        $TempVar | Export-Csv -Path $Report -Delimiter ';'

        # On ajoute les valeurs pour Nagios
        $ReportData = Import-Csv -Path 'C:\Scripts\AntivirusState\Report.dat' -Delimiter ';'
        $ReportData | Add-Member -MemberType NoteProperty -Name "Total" -Value $TotalPC
        $ReportData | Add-Member -MemberType NoteProperty -Name "Verif" -Value $PCOnline
        $ReportData | Add-Member -MemberType NoteProperty -Name "Offline" -Value $PCOffline
        $ReportData | Add-Member -MemberType NoteProperty -Name "RTFail" -Value $PCWithFaultyRT
        $ReportData | Add-Member -MemberType NoteProperty -Name "Obsolete" -Value $PCWithObsoleteBase
        $ReportData | Add-Member -MemberType NoteProperty -Name "TooMany" -Value $PCWithManyAV
        $ReportData | Add-Member -MemberType NoteProperty -Name "NoAV" -Value $PCWithoutAV
        $ReportData | Export-Csv -Path 'C:\Scripts\AntivirusState\Report.dat' -Delimiter ';'
    }

#############################################################################################################
#                                                                                                           #
# Traitement par Nagios du rapport de Get-AntiVirusState.ps1                                                #
#                                                                                                           #
# Par Nicolas THOREZ                                                                                        #
#                                                                                                           #
#############################################################################################################

$Report = Import-Csv -Path 'C:\Scripts\AntivirusState\Report.dat' -Delimiter ';'

[int]$Total = $Report.Total
[int]$Verif = $Report.Verif
[int]$Offline = $Report.Offline
[String]$RTFail = $Report.RTFail
[String]$Obsolete = $Report.Obsolete
[String]$TooMany = $Report.TooMany
[String]$NoAV = $Report.NoAV

$Output = ''
$OutputMessage = ''
$ExitCode = 3

If ($NoAV -ne "n/a")
    {
        $Output = "Critical"
        $OutputMessage = "PC without AV : $NoAV"
        $ExitCode = 2
    }
Elseif ($TooMany -ne "n/a")
    {
        $Output = "Critical"
        If ($OutputMessage -eq '')
            {
                $OutputMessage = "PC with too many AV : $TooMany"
            }
        Else
            {
                $OutputMessage += ", PC with too many AV : $TooMany"
            }
        $ExitCode = 2
    }
Elseif ($RTFail -ne "n/a")
    {
        $Output = "Critical"
        If ($OutputMessage -eq '')
            {
                $OutputMessage = "PC without activated RealTime Protection : $RTFail"
            }
        Else
            {
                $OutputMessage += ", PC without activated RealTime Protection : $RTFail"
            }
        $ExitCode = 2
    }
If ($Obsolete -ne "n/a")
    {
        If ($Output -eq '')
            {
                $Output = "Warning"
                $ExitCode = 1
            }
        If ($OutputMessage -eq '')
            {
                $OutputMessage = "PC with obsolete virus definitions bases : $Obsolete"
            }
        Else
            {
                $OutputMessage += ", PC with obsolete virus definitions bases : $Obsolete"
            }
    }
If (($NoAV -eq "n/a") -and ($TooMany -eq "n/a") -and ($RTFail -eq "n/a") -and ($Obsolete -eq "n/a"))
    {
        $Output = "OK - Total : $Total, Verified : $Verif, Offline : $Offline"
        exit 0
    }
ElseIf (($ExitCode -eq 1) -or ($ExitCode -eq 2))
    {
        $FinalOutput = "$Output - Total : $Total, Verified : $Verif, Offline : $Offline -- $OutputMessage"
        Write-Host $FinalOutPut
        exit $ExitCode
    }
Else
    {
        Write-Host "Unknown - Error in Report.dat, please check"
        exit $ExitCode
    }

Entrer votre commentaire. La syntaxe wiki est autorisée:
 
  • antivirusstate.txt
  • Dernière modification : 2021/03/05 16:13
  • de nekan