# Disable unattended sleep timeout (if computer was woken up by an unattended process, this timer kicks in)
#   The default value for this setting is 120 (2 minutes)
#   Aliases:
#     SUB_SLEEP     = 238c9fa8-0aad-41ed-83f4-97be242c8f20
#     UNATTENDSLEEP = 7bc4a2f9-d8fc-4469-b07b-33eb785aaca0
$UnattendedSleepTimeout = 0
Try {
    Start-Process "powercfg.exe" -ArgumentList "/setacvalueindex SCHEME_CURRENT SUB_SLEEP UNATTENDSLEEP ${UnattendedSleepTimeout}" -Wait
    Start-Process "powercfg.exe" -ArgumentList "/setdcvalueindex SCHEME_CURRENT SUB_SLEEP UNATTENDSLEEP ${UnattendedSleepTimeout}" -Wait
}
Catch { Write-Error $_.Exception.Message }