PRTG Skript for Monitoring Ntfs Errors in Windows Eventlog

$hostname = „hostname.domainname.tld“
$threshold = 0
$days = 2
$username = „DOMAIN\administrator“

$password = „p4ssw0rd“
$secpasswd = ConvertTo-SecureString $password -AsPlainText -Force

$credentials= New-Object System.Management.Automation.PSCredential ($username, $secpasswd)

$ErrorCount = Get-WinEvent -ComputerName $hostname -ProviderName „Microsoft-Windows-Ntfs“ -Credential $credentials | Where-Object LevelDisplayName -eq
„Fehler“ | Where-Object TimeCreated -gt $((Get-Date) – (New-TimeSpan -Day $days)) | Measure-Object | Select-Object -expand Count

if ($ErrorCount -eq $threshold) {
  Write-Host „${ErrorCount}:$Errorcount event(s) for Ntfs errors on $hostname in the last $days days – OK“
}
else {
  Write-Host „${ErrorCount}:$Errorcount event(s) for Ntfs errors on $hostname in the last $days days – CRIT“
}

Schreibe einen Kommentar