Différences

Ci-dessous, les différences entre deux révisions de la page.

Lien vers cette vue comparative

Les deux révisions précédentes Révision précédente
Prochaine révision
Révision précédente
antivirusstate [2019/05/21 10:43] – [Get-AntiVirusState - Connaître l'état des antivirus d'un parc] nekanantivirusstate [2021/03/05 16:13] (Version actuelle) nekan
Ligne 1: Ligne 1:
-~~CLOSETOC~~ 
 ====== Get-AntiVirusState - Connaître l'état des antivirus d'un parc ====== ====== Get-AntiVirusState - Connaître l'état des antivirus d'un parc ======
 +<label type="info">Création</label> --- //[[nekan@shyrkasystem.com|Nicolas 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". 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".
Ligne 10: Ligne 10:
 ===== Script principal ===== ===== Script principal =====
  
-<code:ps1># Ligne rajoutée pour permettre la coloration syntaxique. A supprimer.+<sxh powershell>
 <# <#
 .SYNOPSIS .SYNOPSIS
Ligne 113: Ligne 113:
  
 Param( Param(
-    [String[]]$PC='All',+    [String[]]$PC="All",
     [Switch]$Nagios,     [Switch]$Nagios,
     [Switch]$Verbose     [Switch]$Verbose
Ligne 120: 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,OU=Ordinateurs,DC=TEST,DC=LOCAL" -Filter *).Name         $ListPC = (Get-ADComputer -SearchBase "OU=PC Fixe,OU=Ordinateurs,DC=TEST,DC=LOCAL" -Filter *).Name
Ligne 145: Ligne 145:
 $PCWithFaultyRT = "n/a" $PCWithFaultyRT = "n/a"
 $PCWithObsoleteBase = "n/a" $PCWithObsoleteBase = "n/a"
-$Domaine = 'TEST' +$Domaine = "TEST" 
-$FQDN = 'test.local'+$FQDN = "test.local"
 $Report = "$Path\Report.dat" $Report = "$Path\Report.dat"
  
Ligne 167: Ligne 167:
         Else         Else
             {             {
-                $CheckTime = Get-Date -Format 'G'+                $CheckTime = Get-Date -Format G
                 If ($Verbose)                 If ($Verbose)
                     {                     {
Ligne 298: 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]::ToString($productState, 16).PadLeft(6,'0'+                $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)                 # Séparation des indicateurs (les 2 premiers caractères puis les 2 suivants et enfin les 2 derniers)
Ligne 306: 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 318: 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 331: 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 += "Internet Settings"                                         $Provider += "Internet Settings"
Ligne 344: 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 += "AntiSpyware"                                         $Provider += "AntiSpyware"
Ligne 357: 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 += "Antivirus"                                         $Provider += "Antivirus"
Ligne 370: 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 += "AutoUpdate"                                         $Provider += "AutoUpdate"
Ligne 383: 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 += "FireWall"                                         $Provider += "FireWall"
Ligne 394: Ligne 394:
                             }                             }
                     }                     }
-                If ($Provider -eq "")+                If ($Provider -eq '')
                     {                     {
                         $Provider = "None"                         $Provider = "None"
Ligne 591: Ligne 591:
         $ReportData | Export-Csv -Path 'C:\Scripts\AntivirusState\Report.dat' -Delimiter ';'         $ReportData | Export-Csv -Path 'C:\Scripts\AntivirusState\Report.dat' -Delimiter ';'
     }     }
-</code>+</sxh>
  
 ===== Script d'interprétation Nagios ===== ===== Script d'interprétation Nagios =====
  
-<code:ps1>+<sxh powershell>
 ############################################################################################################# #############################################################################################################
 #                                                                                                           # #                                                                                                           #
Ligne 614: Ligne 614:
 [String]$NoAV = $Report.NoAV [String]$NoAV = $Report.NoAV
  
-$Output = "" +$Output = '' 
-$OutputMessage = ""+$OutputMessage = ''
 $ExitCode = 3 $ExitCode = 3
  
Ligne 627: Ligne 627:
     {     {
         $Output = "Critical"         $Output = "Critical"
-        If ($OutputMessage -eq "")+        If ($OutputMessage -eq '')
             {             {
                 $OutputMessage = "PC with too many AV : $TooMany"                 $OutputMessage = "PC with too many AV : $TooMany"
Ligne 640: Ligne 640:
     {     {
         $Output = "Critical"         $Output = "Critical"
-        If ($OutputMessage -eq "")+        If ($OutputMessage -eq '')
             {             {
                 $OutputMessage = "PC without activated RealTime Protection : $RTFail"                 $OutputMessage = "PC without activated RealTime Protection : $RTFail"
Ligne 652: Ligne 652:
 If ($Obsolete -ne "n/a") If ($Obsolete -ne "n/a")
     {     {
-        If ($Output -eq "")+        If ($Output -eq '')
             {             {
                 $Output = "Warning"                 $Output = "Warning"
                 $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 682: Ligne 682:
         exit $ExitCode         exit $ExitCode
     }     }
-</code> +</sxh>
- +
- --- //[[nekan@shyrkasystem.com|Nicolas THOREZ]] 2019/02/19 19:58//+
  
 ~~DISCUSSION~~ ~~DISCUSSION~~
  
  
  • antivirusstate.1558428188.txt.gz
  • Dernière modification : 2019/05/21 08:43
  • (modification externe)