Skip to content

Commit 1cb142e

Browse files
authored
Update CheckForRestartsAndUptime.ps1
- Improve handling of larger log files - Typo fix
1 parent 2c14e04 commit 1cb142e

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

CheckForRestartsAndUptime.ps1

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ $ActualUptime = $CurrentTime - $LastBoot
3737
$UptimeMessage = "Server has been up for $ActualUptime hours"
3838

3939
#Get events
40-
$Events = Get-WinEvent -LogName system -Oldest | Where-Object -Property Id -in $EventIDs
40+
$Events = Get-WinEvent -FilterHashtable @{LogName='System';ID=$EventIDs} -Oldest
4141
$EventsFiltered = $Events | Where-Object {(($CurrentTime - $_.TimeCreated).TotalHours) -le $MaxEventAge} | Select-Object -Property *
4242

4343
#Reformat event info
@@ -57,7 +57,7 @@ $EventsReformat = foreach ($EventLog in $EventsFiltered) {
5757
$SIDID1 = (($EventLog.UserId.Value.ToString()) -split '-')[3]
5858
$SIDTest1 = $SIDID1 -in 0..20
5959
}
60-
#Test for Get-ADUser abilities. Will reports AD user if able
60+
#Test for Get-ADUser abilities. Will report AD user if able
6161
$PreErrorCheck = $Error.Count
6262
$ADUserAbility = (Get-Command Get-ADUser -ErrorAction SilentlyContinue).count -gt 0
6363
if ($PreErrorCheck -lt 1) {

0 commit comments

Comments
 (0)