workans
This commit is contained in:
@@ -14,6 +14,39 @@ $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"))
|
||||||
|
|
||||||
|
function NotifyUser {
|
||||||
|
# notify user
|
||||||
|
## Warning
|
||||||
|
Write-Host "`nFORCING YOUR STUPID ASS OFF IN $Hours hours $Minutes minutes plus $GraceMinutes minutes grace period`n"
|
||||||
|
## current time
|
||||||
|
Write-Host "$(Get-Date -Format 'hh:mm:ss tt') | Start Time"
|
||||||
|
## shutdown time
|
||||||
|
Write-Host "$reboot_time | Reboot Time"
|
||||||
|
## send da webhookd thingggg
|
||||||
|
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
|
||||||
|
Start-Sleep -Seconds $total_wait_seconds
|
||||||
|
|
||||||
|
# do reboot
|
||||||
|
## schedule shutdown
|
||||||
|
## redundant but also for warnings
|
||||||
|
### reboot (-r) forced (-t) in seconds (-t)
|
||||||
|
shutdown -r -f -t ($total_wait_seconds+10) # 10 second bonus to defer to Start-MpWDOScan
|
||||||
|
## Start Windows Defender Offline Scan
|
||||||
|
## wastes time
|
||||||
|
## does the actual reboot
|
||||||
|
Start-MpWDOScan
|
||||||
|
}
|
||||||
|
|
||||||
|
# force admin and disable previously scheduled shutdown
|
||||||
# environment
|
# environment
|
||||||
## Check for administrator privileges
|
## Check for administrator privileges
|
||||||
if (-not ([Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator)) {
|
if (-not ([Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator)) {
|
||||||
@@ -22,32 +55,10 @@ if (-not ([Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdenti
|
|||||||
exit
|
exit
|
||||||
}
|
}
|
||||||
## clean up any sched backups
|
## clean up any sched backups
|
||||||
shutdown /a
|
shutdown -a
|
||||||
|
|
||||||
# time wasters
|
# post to terminal and send webhook
|
||||||
## checks C drive after reboot to waste time and fix errors
|
NotifyUser
|
||||||
## chkdsk /r C: # as admin
|
|
||||||
chkdsk /r C:
|
|
||||||
|
|
||||||
# notify user
|
# fork dis one to backgruond
|
||||||
## Warning
|
ForceOff &
|
||||||
Write-Host "`nFORCING YOUR STUPID ASS OFF IN $Hours hours $Minutes minutes plus $GraceMinutes minutes grace period`n"
|
|
||||||
## current time
|
|
||||||
Write-Host "$(Get-Date -Format 'hh:mm:ss tt') | Start Time"
|
|
||||||
## shutdown time
|
|
||||||
Write-Host "$reboot_time | Reboot Time"
|
|
||||||
## send da webhookd thingggg
|
|
||||||
webhook "FORCING OFF FROM WINDOWS AT $reboot_time" true
|
|
||||||
|
|
||||||
# Do the sleep
|
|
||||||
Start-Sleep -Seconds $total_wait_seconds
|
|
||||||
|
|
||||||
# do reboot
|
|
||||||
## schedule shutdown
|
|
||||||
## redundant but also for warnings
|
|
||||||
### reboot (-r) forced (-t) in seconds (-t)
|
|
||||||
shutdown -r -f -t ($total_wait_seconds+10)
|
|
||||||
## Start Windows Defender Offline Scan
|
|
||||||
## wastes time
|
|
||||||
## does the actual reboot
|
|
||||||
Start-MpWDOScan
|
|
||||||
Reference in New Issue
Block a user