|
2 | 2 |
|
3 | 3 | #Reference
|
4 | 4 | #Event Log ID | Meaning
|
5 |
| -#41 | The system has rebooted without cleanly shutting down first |
6 |
| -#1074 | The system has been shutdown properly by a user or process |
7 |
| -#1076 | Follows after EventLog.Id ID 6008 and means that the first user with shutdown privileges logged on to the server after an unexpected restart or shutdown and specified the cause |
8 |
| -#6005 | The EventLog.Id Log service was started. Indicates the system startup |
9 |
| -#6006 | The EventLog.Id Log service was stopped. Indicates the proper system shutdown |
10 |
| -#6008 | The previous system shutdown was unexpected |
11 |
| -#6009 | The operating system version detected at the system startup |
12 |
| -#6013 | The system uptime in seconds |
| 5 | +#41 | The system has rebooted without cleanly shutting down first |
| 6 | +#1074 | The system has been shutdown properly by a user or process |
| 7 | +#1076 | Follows after EventLog.Id ID 6008 and means that the first user with shutdown privileges logged on to the server after an unexpected restart or shutdown and specified the cause |
| 8 | +#6005 | The EventLog.Id Log service was started. Indicates the system startup |
| 9 | +#6006 | The EventLog.Id Log service was stopped. Indicates the proper system shutdown |
| 10 | +#6008 | The previous system shutdown was unexpected |
| 11 | +#6009 | The operating system version detected at the system startup |
| 12 | +#6013 | The system uptime in seconds |
13 | 13 |
|
14 | 14 | [int32]$WarningUptime = $args[0] #Uptime in total hours. Example, if you want 3 days enter 72
|
15 | 15 | [int32]$CriticalUptime = $args[1] #Uptime in total hours.
|
16 |
| -[int32]$MaxEventAge = $args[2] #In total hours. Don't look back more than X hours in the event log |
| 16 | +[int32]$MaxEventAge = $args[2] #Uptime in total hours. Don't look back more than X hours in the event log |
17 | 17 |
|
18 | 18 | #-----------------
|
19 | 19 |
|
20 | 20 | #Validate input
|
21 | 21 | if ($Error.Count -gt 0) {
|
22 | 22 | $LASTEXITCODE = 3
|
23 | 23 | Clear-Host
|
24 |
| - Write-Output 'UNKNOWN: Only use Int32 numbers for the arguments' |
| 24 | + Write-Output 'UNKNOWN: Use only Int32 numbers for the arguments' |
25 | 25 | exit $LASTEXITCODE
|
26 | 26 | }
|
27 | 27 |
|
@@ -81,25 +81,25 @@ $EventsReformat = foreach ($EventLog in $EventsFiltered) {
|
81 | 81 |
|
82 | 82 | #Get counts of event level types
|
83 | 83 | $CriticalCount = ($EventsReformat | Where-Object -Property Level -EQ 'Critical')
|
84 |
| -if (($null -ne $CriticalCount) -and $null -eq $CriticalCount.Count) { |
| 84 | +if (($null -ne $CriticalCount) -and ($null -eq $CriticalCount.Count)) { |
85 | 85 | $CriticalCount = 1
|
86 | 86 | } else {
|
87 | 87 | $CriticalCount = $CriticalCount.Count
|
88 | 88 | }
|
89 | 89 | $ErrorCount = ($EventsReformat | Where-Object -Property Level -EQ 'Error')
|
90 |
| -if (($null -ne $ErrorCount) -and $null -eq $ErrorCount.Count) { |
| 90 | +if (($null -ne $ErrorCount) -and ($null -eq $ErrorCount.Count)) { |
91 | 91 | $ErrorCount = 1
|
92 | 92 | } else {
|
93 | 93 | $ErrorCount = $ErrorCount.Count
|
94 | 94 | }
|
95 | 95 | $WarningCount = ($EventsReformat | Where-Object -Property Level -EQ 'Warning')
|
96 |
| -if (($null -ne $WarningCount) -and $null -eq $WarningCount.Count) { |
| 96 | +if (($null -ne $WarningCount) -and ($null -eq $WarningCount.Count)) { |
97 | 97 | $WarningCount = 1
|
98 | 98 | } else {
|
99 | 99 | $WarningCount = $WarningCount.Count
|
100 | 100 | }
|
101 | 101 | $InfoCount = ($EventsReformat | Where-Object -Property Level -EQ 'Information')
|
102 |
| -if (($null -ne $InfoCount) -and $null -eq $InfoCount.Count) { |
| 102 | +if (($null -ne $InfoCount) -and ($null -eq $InfoCount.Count)) { |
103 | 103 | $InfoCount = 1
|
104 | 104 | } else {
|
105 | 105 | $InfoCount = $InfoCount.Count
|
@@ -149,7 +149,8 @@ if ($LASTEXITCODE -eq 0) {
|
149 | 149 | Write-Output "Warning trigger: $WarningUptime hours"
|
150 | 150 | Write-Output "Critical trigger: $CriticalUptime hours"
|
151 | 151 | Write-Output "Max event age: $MaxEventAge hours"
|
152 |
| -if ($EventsReformat.Count -gt 0) { |
| 152 | + |
| 153 | +if ($Null -ne $EventsReformat) { |
153 | 154 | Write-Output '
|
154 | 155 | =====
|
155 | 156 | Events
|
|
0 commit comments