Last active
April 7, 2021 01:47
-
-
Save keyboardcrunch/5da6b14a299c7c78c0699613fe7e27bb to your computer and use it in GitHub Desktop.
Check if a system rebooted after a SentinelOne agent upgrade or install.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$SentinelOne = Get-WmiObject -Class Win32Reg_AddRemovePrograms | Where-Object { $_.DisplayName -eq "Sentinel Agent" } | |
$Boot = Get-WmiObject -class Win32_OperatingSystem | Select-Object __SERVER,@{label='LastRestart';expression={$_.ConvertToDateTime($_.LastBootUpTime)}} | |
If ( $SentinelOne ) { | |
# Quick date-time conversion | |
$InstallDate = Get-Date $([Datetime]::ParseExact($SentinelOne.InstallDate, 'yyyyMMdd', $null)) | |
$LastRestart = Get-Date $Boot.LastRestart | |
#Write-Host "Last Reboot: $LastRestart" | |
#Write-Host "S1 Installed: $InstallDate" | |
If ( $InstallDate -gt $LastRestart ) { | |
# LastRestart should be greater than InstallDate if system rebooted after upgrade. | |
# This If statement should evaluate to $false if system still requires a reboot. | |
return $false | |
} Else { | |
# LastRestart newer/greater than InstallDate, system is compliant. | |
return $true | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment