Script de rapport des erreur 500 sur IIS

par | Oct 15, 2015 | PowerShell | 0 commentaires

 

Ce script génère un rapport texte des erreurs 500 en parsant les logs IIS d’une liste de serveurs. (Lien du script plus bas).

#SCRIPT REMONTANT LES OCCURENCES DES ERREURS ‘500’ DANS LES LOGS IIS DE PLUSIEURS SERVEURS #INTERVALLE DE TEMPS PAR DEFAUT: Journée d’hier ($firstdate –> $date) #MODIFIER EN FONCTION, LE COMPTE UTILISE ($cred), LE CHEMIN DU RAPPORT ($rapport), LES NOMS DES SERVEURS ($FrontServers), LE CHEMIN DES LOGS ($Logpath) # #PAR DEFAUT L’INTERVALLE DE TEMPS EST CELUI DE LA JOURNEE DE LA VEILLE. $cred= GetCredential Credential « MYDOMAIN\«  $rapport = « D:\Temp\error500.txt«  $date = (getdate).Date $firstdate = (getdate).Date.AddDays(1) $FrontServers=(« SERVEUR1« ,« SERVEUR2« ,« SERVEUR3« ,« SERVEUR4« ) $Logpath=« c$\inetpub\logs\logfiles«  $Header= « ########### ERREURS 500 SUR LES FRONTAUX IIS ( $firstdate —> $date ) ############## ######################################################################################################################«  #suppression fichier rapport if (TestPath $rapport) { RemoveItem $rapport } #ajout de l’entete au rapport $Header | Out-File FilePath $rapport «  » | Out-File FilePath $rapport Append «  » | Out-File FilePath $rapport Append Function GetError500 ($Front,$cred) { #chaine 500 (!entourée de deux espaces!) $pattern=«  500 «  NewPSDrive Name « $Front`_drive«  Credential $cred Root \\$Front\$Logpath PSProvider FileSystem | OutNull $logs= GetChildItem Path « $Front`_drive:\*.log«  Recurse | WhereObject {$_.LastWriteTime -ge $firstdate -AND $_.LastWriteTime -lt $date} | SelectObject foreach ($log in $logs) { writehost BackgroundColor White ForegroundColor Blue « LOG: $log«  « LOG: $log«  | Out-File $rapport Append «  » | Out-File $rapport Append getcontent Path $log | SelectString Pattern $pattern | SelectObject Property Line | Out-File $rapport Append } RemovePSDrive Name « $Front`_drive«  Force } foreach ($Front in $FrontServers) { WriteHost ForegroundColor Yellow « —-SERVEUR $Front—- :«  « —-SERVEUR $Front—- :«  | Out-File Append $rapport GetError500 Front $Front cred $cred WriteHost «  » WriteHost « ***************************************************************************************************************«  WriteHost «  » «  » | Out-File Append $rapport « ***************************************************************************************************************«  | Out-File Append $rapport «  » | Out-File Append $rapport }

 

0 commentaires

Soumettre un commentaire

Votre adresse e-mail ne sera pas publiée. Les champs obligatoires sont indiqués avec *