Hi TechUST,
Please use the shutdown
command in Windows to schedule a restart. The /r
switch is for restart, the /t
switch specifies the time delay in seconds, and the /c
switch is for the comment that will be shown in the notification.
requires -runasadministrator
restart the machine after 8 hours and show a notification before restarting
Set-ExecutionPolicy Bypass -Scope Process -Force
try {
Get-CimInstance -Namespace root/WMI -ClassName Lenovo_SetBiosSetting | Invoke-CimMethod -MethodName SetBiosSetting -Arguments @{parameter = "UserPresenceSensing,Disable" }
Get-CimInstance -Namespace root/WMI -ClassName Lenovo_SaveBiosSettings | Invoke-CimMethod -MethodName SaveBiosSettings
Write-Output "User Presence Sensing is Disabled."
shutdown.exe /r /t 28800 /c "System will restart in 8h"
return 0
} catch {
Write-Output $_.Exception.Message
return 1
}
# If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".