1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
| # Logon Script that will auto-logoff a user after a specified amount of time has passed,
# and will give a warning of the impending logoff at a specified amount of time beforehand.
# The Warning Message has 10 second timeout so that the user can't postpone the logoff forever.
$maxTime = 1 # hours
$warnTime = 30 # minutes
$msgTimeout = 10 # seconds
$WarningMSG = "Attention "user" ! Fermeture de session dans $warnTime secondes"
# ========================================================================================================
# Calculate Time To Sleep
$sleepyTime = $maxTime * 60 * 1
$warningTime = $warnTime * 1
Sleep -Seconds ($sleepyTime - $warningTime)
$wshell = New-Object -ComObject Wscript.Shell
$wshell.Popup($WarningMSG,$msgTimeout,"Automatic Logoff Incoming...",0x0)
Sleep -Seconds $warningTime
# ADD LOGOFF CODE BELOW!
Shutdown -l -f
Shutdown -l -f |
Partager