Jump to content

Recommended Posts

Posted

Hi Folks,

 

The old lemon of shutting down PC's again is rearing its ugly head.

We had a shutdown scheduled task sent to every PC via GPO, but thanks to this:

https://support.microsoft.com/en-us/kb/2962486

It no longer works. We get a security warning.

 

The scheduled task is to start a programme:

C:\Windows\System32\shutdown.exe

with the arguments:

-s -f -t 1800 -c "Automatic Shut Down Commencing. To postpone this click on 'Abort Shutdown' on the Desktop"

 

It runs as a separate shutdown user.

 

Has anyone found a workaround or know of another way we could make this work?

We've been using impero in the meantime, but to call it unreliable would be an understatement.

Posted

would a .bat file on a server that run something long the lines of:

shutdown.exe -m "CVWS-ADM-0100" -s -f -t 1800 -c "Automatic Shut Down Commencing. To postpone this click on 'Abort Shutdown' on the Desktop"

work?

Posted (edited)

powershell - Stop-Computer [[-ComputerName] ] [[-Credential] So something like

 

$objWks = get-adcomputer -server [YourDC] -SearchBase "ou=[YourWorkStationOu],dc=le,dc=ac,dc=uk - Filter {IFYouWantOne} -Properties *

 

$objWks.name | % {stop-computer}

 

You could add in a test-connection so it only sends the stop-computer to computers that are really there, you should also make it output a log file so you can see what's going on. You could also add a wait and retest to make sure the computer is shutdown and if not add that to the log so you can check out why computers are not shutting down, you can test if it has an active user session before you get the boot for killing the heads machine! so on and......

Edited by HPlum78
missing $
  • 2 weeks later...
Posted

Managed to fix it now.

Turns out we were using an old group policy method, using a group policy preference instead to make the scheduled task has worked

 

Run shutdown.exe

arguments:

/s /f /c "computer will shutdown in 30 mins pres the desktop icon to cancel" /t 1600

 

Icon on the desktop runs:

shutdown.exe /a

  • 2 weeks later...
Posted (edited)

I wrote this script and works reliably.

I have a scheduled task to run at 6pm every day

 

####IPcheck.cmd###

This script searches each of your VLANS ( dont put it obviously on your server vlan :)

 

Del c:\shutdown\iplist.txt    @echo 
md c:\shutdown\Logs\%date:/=-%
Echo ###Script Start at %Time% ### >> c:\shutdown\Logs\%date:/=-%\Log.txt
For /L %%f in (4,1,254) Do Ping.exe -n 1 -w 500 192.168.60.%%f | Find "Reply from" && echo 192.168.60.%%f >> IPList.txt && echo off
For /L %%f in (50,1,254) Do Ping.exe -n 1 -w 500 192.168.64.%%f | Find "Reply from" && echo 192.168.64.%%f >> IPList.txt && echo off
For /L %%f in (0,1,254) Do Ping.exe -n 1 -w 500 192.168.65.%%f | Find "Reply from" && echo 192.168.65.%%f >> IPList.txt && echo off
For /L %%f in (0,1,254) Do Ping.exe -n 1 -w 500 192.168.66.%%f | Find "Reply from" && echo 192.168.66.%%f >> IPList.txt && echo off

for /f %%k in (iplist.txt) do (
	shutdown.exe /s /f /t 600 /m \\%%k /c "The computer is due to shutdown in 10 minutes as part of a power saving scheme. Please save any work and log off. Thank You and Goodnight - ICT Team."
rem	c:\shutdown\psshutdown.exe \\%%k -accepteula -r -f -c -t 5 -n 1 -m "The computer is shutting down due to Power Saving. Save any work and log off. Thanks - ICT Team. If you are still working please click cancel and continue working, please make sure you shutdown the machine afterwards. "  
echo %%k is shutting down at %Date% %Time% >> c:\shutdown\Logs\%date:/=-%\Log.txt
 )
)
Echo ###Script Finish at %Time% ### >> c:\shutdown\Logs\%date:/=-%\Log.txt
Echo ##################################################################### >> c:\shutdown\Logs\%date:/=-%\Log.txt

 

###WhoseAlive.cmd####

This script i run at 11pm every night which runs throughv the network again and generated a text log of the computers IP address that failed shutdown and nslookup the hostname in another text log. this helps find problems with unreported computer issue. mainly like unplugged Network lead

  @echo 
md c:\shutdown\Logs\%date:/=-%
Echo ###Script Start at %Time% ### >> c:\shutdown\Logs\%date:/=-%\WhoseAlive.txt
For /L %%f in (1,1,254) Do Ping.exe -n 1 -w 500 192.168.60.%%f | Find "Reply from" && echo 192.168.60.%%f >> c:\shutdown\Logs\%date:/=-%\WhoseAlive.txt && echo off
For /L %%f in (50,1,254) Do Ping.exe -n 1 -w 500 192.168.64.%%f | Find "Reply from" && echo 192.168.64.%%f >> c:\shutdown\Logs\%date:/=-%\WhoseAlive.txt && echo off
For /L %%f in (0,1,254) Do Ping.exe -n 1 -w 500 192.168.65.%%f | Find "Reply from" && echo 192.168.65.%%f >> c:\shutdown\Logs\%date:/=-%\WhoseAlive.txt && echo off
For /L %%f in (0,1,254) Do Ping.exe -n 1 -w 500 192.168.66.%%f | Find "Reply from" && echo 192.168.66.%%f >> c:\shutdown\Logs\%date:/=-%\WhoseAlive.txt && echo off
For /L %%f in (50,1,254) Do Ping.exe -n 1 -w 500 192.168.254.%%f | Find "Reply from" && echo 192.168.254.%%f >> c:\shutdown\Logs\%date:/=-%\WhoseAlive.txt && echo off
Echo ###Script Finish at %Time% ### >> c:\shutdown\Logs\%date:/=-%\WhoseAlive.txt
Echo ##################################################################### >> c:\shutdown\Logs\%date:/=-%\WhoseAlive.txt
Echo ##################################################################### >> c:\shutdown\Logs\%date:/=-%\check.txt
Echo ###Script Start at %Time% ### >> c:\shutdown\Logs\%date:/=-%\check.txt
Echo ##################################################################### >> c:\shutdown\Logs\%date:/=-%\check.txt
for /F %%d in (c:\shutdown\Logs\%date:/=-%\WhoseAlive.txt) do nslookup %%d | find "Name" >> c:\shutdown\Logs\%date:/=-%\check.txt
Echo ##################################################################### >> c:\shutdown\Logs\%date:/=-%\check.txt
Echo ###Script Finish at %Time% ### >> c:\shutdown\Logs\%date:/=-%\check.txt
Echo ##################################################################### >> c:\shutdown\Logs\%date:/=-%\check.txt

Edited by dapaulio

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now



×
×
  • Create New...