Différences
Ci-dessous, les différences entre deux révisions de la page.
| Les deux révisions précédentes Révision précédente Prochaine révision | Révision précédente | ||
| antivirusstate [2019/04/08 16:41] – [Script principal] nekan | antivirusstate [2021/03/05 16:13] (Version actuelle) – nekan | ||
|---|---|---|---|
| Ligne 1: | Ligne 1: | ||
| ====== Get-AntiVirusState - Connaître l' | ====== Get-AntiVirusState - Connaître l' | ||
| + | <label type=" | ||
| Connaître l' | Connaître l' | ||
| Ligne 9: | Ligne 10: | ||
| ===== Script principal ===== | ===== Script principal ===== | ||
| - | <code:ps1># Ligne rajoutée pour permettre la coloration syntaxique. A supprimer. | + | <sxh powershell> |
| <# | <# | ||
| .SYNOPSIS | .SYNOPSIS | ||
| + | |||
| + | |||
| + | ███████╗██╗ | ||
| + | ██╔════╝██║ | ||
| + | ███████╗███████║ ╚████╔╝ ██████╔╝█████╔╝ ███████║ | ||
| + | ╚════██║██╔══██║ | ||
| + | ███████║██║ | ||
| + | ╚══════╝╚═╝ | ||
| + | |||
| + | ███████╗██╗ | ||
| + | ██╔════╝╚██╗ ██╔╝██╔════╝╚══██╔══╝██╔════╝████╗ ████║ | ||
| + | ███████╗ ╚████╔╝ ███████╗ | ||
| + | ╚════██║ | ||
| + | ███████║ | ||
| + | ╚══════╝ | ||
| + | |||
| + | |||
| ############################################################################################################# | ############################################################################################################# | ||
| Ligne 71: | Ligne 89: | ||
| NOM : Get-AntiVirusState.ps1 | NOM : Get-AntiVirusState.ps1 | ||
| AUTEUR : | AUTEUR : | ||
| - | VERSION : 1.2 | + | VERSION : 1.3 |
| HISTORIQUE : | HISTORIQUE : | ||
| Ligne 88: | Ligne 106: | ||
| 1.2 | 1.2 | ||
| + | 1.3 | ||
| #> | #> | ||
| Ligne 94: | Ligne 113: | ||
| Param( | Param( | ||
| - | [String[]]$PC='All', | + | [String[]]$PC="All", |
| [Switch]$Nagios, | [Switch]$Nagios, | ||
| [Switch]$Verbose | [Switch]$Verbose | ||
| Ligne 101: | Ligne 120: | ||
| # Déclaration des variables | # Déclaration des variables | ||
| - | If ($PC -eq 'All') | + | If ($PC -eq "All") |
| { | { | ||
| $ListPC = (Get-ADComputer -SearchBase "OU=PC Fixe, | $ListPC = (Get-ADComputer -SearchBase "OU=PC Fixe, | ||
| Ligne 126: | Ligne 145: | ||
| $PCWithFaultyRT = " | $PCWithFaultyRT = " | ||
| $PCWithObsoleteBase = " | $PCWithObsoleteBase = " | ||
| - | $Domaine = 'TEST' | + | $Domaine = "TEST" |
| - | $FQDN = 'test.local' | + | $FQDN = "test.local" |
| $Report = " | $Report = " | ||
| Ligne 148: | Ligne 167: | ||
| Else | Else | ||
| { | { | ||
| - | $CheckTime = Get-Date -Format | + | $CheckTime = Get-Date -Format G |
| If ($Verbose) | If ($Verbose) | ||
| { | { | ||
| Ligne 232: | Ligne 251: | ||
| $PCOnline += 1 | $PCOnline += 1 | ||
| #On vérifie le nombre d' | #On vérifie le nombre d' | ||
| - | $AntiVirusCount = (Get-WmiObject -Namespace " | ||
| $AntiVirusProduct = Get-WmiObject -Namespace " | $AntiVirusProduct = Get-WmiObject -Namespace " | ||
| + | $AntiVirusCount = $AntiVirusProduct.Count | ||
| If ($AntiVirusCount.Count -gt 2) | If ($AntiVirusCount.Count -gt 2) | ||
| Ligne 253: | Ligne 272: | ||
| { | { | ||
| # Filtre pour supprimer Windows Defender qui doit être désactivé et création de la liste d' | # Filtre pour supprimer Windows Defender qui doit être désactivé et création de la liste d' | ||
| - | $AntiVirusProduct = Get-WmiObject -Namespace " | + | $AntiVirusProduct = Get-WmiObject -Namespace " |
| } | } | ||
| If ($AntiVirusProduct -eq '' | If ($AntiVirusProduct -eq '' | ||
| Ligne 279: | Ligne 298: | ||
| # Conversion en hexadecimal (avec ajout de 0 si nécessaire pour avoir une chaîne de 6 caractères) | # Conversion en hexadecimal (avec ajout de 0 si nécessaire pour avoir une chaîne de 6 caractères) | ||
| - | $Hexa = [Convert]:: | + | $Hexa = [Convert]:: |
| # Séparation des indicateurs (les 2 premiers caractères puis les 2 suivants et enfin les 2 derniers) | # Séparation des indicateurs (les 2 premiers caractères puis les 2 suivants et enfin les 2 derniers) | ||
| Ligne 287: | Ligne 306: | ||
| # Création de la valeur correspondant au type de protection | # Création de la valeur correspondant au type de protection | ||
| - | $Provider = "" | + | $Provider = '' |
| While ($WSC_SECURITY_PROVIDER) | While ($WSC_SECURITY_PROVIDER) | ||
| { | { | ||
| Ligne 299: | Ligne 318: | ||
| { | { | ||
| [Int]$WSC_SECURITY_PROVIDER = [Int]$WSC_SECURITY_PROVIDER - 32 | [Int]$WSC_SECURITY_PROVIDER = [Int]$WSC_SECURITY_PROVIDER - 32 | ||
| - | If ($Provider -eq "" | + | If ($Provider -eq '' |
| { | { | ||
| $Provider += "User Controlled" | $Provider += "User Controlled" | ||
| Ligne 312: | Ligne 331: | ||
| { | { | ||
| [Int]$WSC_SECURITY_PROVIDER = [Int]$WSC_SECURITY_PROVIDER - 16 | [Int]$WSC_SECURITY_PROVIDER = [Int]$WSC_SECURITY_PROVIDER - 16 | ||
| - | If ($Provider -eq "" | + | If ($Provider -eq '' |
| { | { | ||
| $Provider += " | $Provider += " | ||
| Ligne 325: | Ligne 344: | ||
| { | { | ||
| [Int]$WSC_SECURITY_PROVIDER = [Int]$WSC_SECURITY_PROVIDER - 8 | [Int]$WSC_SECURITY_PROVIDER = [Int]$WSC_SECURITY_PROVIDER - 8 | ||
| - | If ($Provider -eq "" | + | If ($Provider -eq '' |
| { | { | ||
| $Provider += " | $Provider += " | ||
| Ligne 338: | Ligne 357: | ||
| { | { | ||
| [Int]$WSC_SECURITY_PROVIDER = [Int]$WSC_SECURITY_PROVIDER - 4 | [Int]$WSC_SECURITY_PROVIDER = [Int]$WSC_SECURITY_PROVIDER - 4 | ||
| - | If ($Provider -eq "" | + | If ($Provider -eq '' |
| { | { | ||
| $Provider += " | $Provider += " | ||
| Ligne 351: | Ligne 370: | ||
| { | { | ||
| [Int]$WSC_SECURITY_PROVIDER = [Int]$WSC_SECURITY_PROVIDER - 2 | [Int]$WSC_SECURITY_PROVIDER = [Int]$WSC_SECURITY_PROVIDER - 2 | ||
| - | If ($Provider -eq "" | + | If ($Provider -eq '' |
| { | { | ||
| $Provider += " | $Provider += " | ||
| Ligne 364: | Ligne 383: | ||
| { | { | ||
| [Int]$WSC_SECURITY_PROVIDER = [Int]$WSC_SECURITY_PROVIDER - 1 | [Int]$WSC_SECURITY_PROVIDER = [Int]$WSC_SECURITY_PROVIDER - 1 | ||
| - | If ($Provider -eq "" | + | If ($Provider -eq '' |
| { | { | ||
| $Provider += " | $Provider += " | ||
| Ligne 375: | Ligne 394: | ||
| } | } | ||
| } | } | ||
| - | If ($Provider -eq "" | + | If ($Provider -eq '' |
| { | { | ||
| $Provider = " | $Provider = " | ||
| Ligne 572: | Ligne 591: | ||
| $ReportData | Export-Csv -Path ' | $ReportData | Export-Csv -Path ' | ||
| } | } | ||
| - | + | </sxh> | |
| - | + | ||
| - | </code> | + | |
| ===== Script d' | ===== Script d' | ||
| - | <code:ps1> | + | <sxh powershell> |
| ############################################################################################################# | ############################################################################################################# | ||
| # # | # # | ||
| Ligne 597: | Ligne 614: | ||
| [String]$NoAV = $Report.NoAV | [String]$NoAV = $Report.NoAV | ||
| - | $Output = "" | + | $Output = '' |
| - | $OutputMessage = "" | + | $OutputMessage = '' |
| $ExitCode = 3 | $ExitCode = 3 | ||
| Ligne 610: | Ligne 627: | ||
| { | { | ||
| $Output = " | $Output = " | ||
| - | If ($OutputMessage -eq "" | + | If ($OutputMessage -eq '' |
| { | { | ||
| $OutputMessage = "PC with too many AV : $TooMany" | $OutputMessage = "PC with too many AV : $TooMany" | ||
| Ligne 623: | Ligne 640: | ||
| { | { | ||
| $Output = " | $Output = " | ||
| - | If ($OutputMessage -eq "" | + | If ($OutputMessage -eq '' |
| { | { | ||
| $OutputMessage = "PC without activated RealTime Protection : $RTFail" | $OutputMessage = "PC without activated RealTime Protection : $RTFail" | ||
| Ligne 635: | Ligne 652: | ||
| If ($Obsolete -ne " | If ($Obsolete -ne " | ||
| { | { | ||
| - | If ($Output -eq "" | + | If ($Output -eq '' |
| { | { | ||
| $Output = " | $Output = " | ||
| $ExitCode = 1 | $ExitCode = 1 | ||
| } | } | ||
| - | If ($OutputMessage -eq "" | + | If ($OutputMessage -eq '' |
| { | { | ||
| $OutputMessage = "PC with obsolete virus definitions bases : $Obsolete" | $OutputMessage = "PC with obsolete virus definitions bases : $Obsolete" | ||
| Ligne 665: | Ligne 682: | ||
| exit $ExitCode | exit $ExitCode | ||
| } | } | ||
| - | </code> | + | </sxh> |
| - | + | ||
| - | --- // | + | |
| ~~DISCUSSION~~ | ~~DISCUSSION~~ | ||