This commit is contained in:
2025-09-26 22:23:14 -06:00
parent 07ec0f941e
commit 2a4d6e124c
+27 -16
View File
@@ -14,21 +14,7 @@ $total_wait_minutes = ($wait_minutes+$GraceMinutes)
$total_wait_seconds = ($total_wait_minutes*60) $total_wait_seconds = ($total_wait_minutes*60)
$reboot_time = $((Get-Date).AddHours($Hours).AddMinutes($Minutes + $GraceMinutes).ToString("hh:mm:ss tt")) $reboot_time = $((Get-Date).AddHours($Hours).AddMinutes($Minutes + $GraceMinutes).ToString("hh:mm:ss tt"))
# environment function NotifyUser {
## Check for administrator privileges
if (-not ([Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator)) {
# Restart with elevated privileges
Start-Process powershell.exe -Verb RunAs -ArgumentList "-File `"$($MyInvocation.MyCommand.Path)`""
exit
}
## clean up any sched backups
shutdown /a
# time wasters
## checks C drive after reboot to waste time and fix errors
## chkdsk /r C: # as admin
chkdsk /r C:
# notify user # notify user
## Warning ## Warning
Write-Host "`nFORCING YOUR STUPID ASS OFF IN $Hours hours $Minutes minutes plus $GraceMinutes minutes grace period`n" Write-Host "`nFORCING YOUR STUPID ASS OFF IN $Hours hours $Minutes minutes plus $GraceMinutes minutes grace period`n"
@@ -38,6 +24,13 @@ Write-Host "$(Get-Date -Format 'hh:mm:ss tt') | Start Time"
Write-Host "$reboot_time | Reboot Time" Write-Host "$reboot_time | Reboot Time"
## send da webhookd thingggg ## send da webhookd thingggg
webhook "FORCING OFF FROM WINDOWS AT $reboot_time" true webhook "FORCING OFF FROM WINDOWS AT $reboot_time" true
}
function ForceOff {
# time wasters
## checks C drive after reboot to waste time and fix errors
## chkdsk /r C: # as admin
chkdsk /r C:
pause # pause for clarity
# Do the sleep # Do the sleep
Start-Sleep -Seconds $total_wait_seconds Start-Sleep -Seconds $total_wait_seconds
@@ -46,8 +39,26 @@ Start-Sleep -Seconds $total_wait_seconds
## schedule shutdown ## schedule shutdown
## redundant but also for warnings ## redundant but also for warnings
### reboot (-r) forced (-t) in seconds (-t) ### reboot (-r) forced (-t) in seconds (-t)
shutdown -r -f -t ($total_wait_seconds+10) shutdown -r -f -t ($total_wait_seconds+10) # 10 second bonus to defer to Start-MpWDOScan
## Start Windows Defender Offline Scan ## Start Windows Defender Offline Scan
## wastes time ## wastes time
## does the actual reboot ## does the actual reboot
Start-MpWDOScan Start-MpWDOScan
}
# force admin and disable previously scheduled shutdown
# environment
## Check for administrator privileges
if (-not ([Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator)) {
# Restart with elevated privileges
Start-Process powershell.exe -Verb RunAs -ArgumentList "-File `"$($MyInvocation.MyCommand.Path)`""
exit
}
## clean up any sched backups
shutdown -a
# post to terminal and send webhook
NotifyUser
# fork dis one to backgruond
ForceOff &