Quantcast
Channel: The Official Scripting Guys Forum! forum
Viewing all articles
Browse latest Browse all 15028

powershell

$
0
0

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


Viewing all articles
Browse latest Browse all 15028

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>