Hi,
When I run the below script manually everything works fine. When I try to run the script as a scheduled task the server is rebooted as normal but the users do not get a popup informing them to save their work and logoff.
Does anyone know why this happens? Any assistance would be greatly appreciated.
here is the script I'm using...
param([int]$timeleft=1)
[System.Reflection.Assembly]::LoadWithPartialName("System.Diagnostics")
$countdowntimer=new-object system.diagnostics.stopwatch
while($timeleft-gt0)
{
$countdowntimer.start()
foreach ($_inget-contentservers.txt) {msg*/SERVER:$_"The server will log you off automatically in $timeleft minutes and reboot to complete the monthly patch cycle"}
while ($countdowntimer.elapsed.minutes-lt1) {write-progress-activity"Elapsed Time"-status$countdowntimer.elapsed}
$countdowntimer.reset()
$timeleft--
}restart-Computer-ComputerName"myserver"-Force
or I run this....
start-job -name forced-user-logoff.ps1 -filepath c:\temp\my-powershell-scripts\forced-user-logoff.ps1.
the users do not get the warning popup.
Rick