1

Anyone know of a way to ensure that a shutdown batch file (Local Computer Policy -> Windows Settings -> Scrips -> Shutdown) is the last thing to run before the machine shuts down?

At the moment the shutdown script is running before the hyper-V virtual machines have been paused, what I want is for the VMs to be paused before the shutdown script runs.

1

what I want is for the VMs to be paused before the shutdown script runs.

You can't choose when your shutdown script runs with that kind of granularity. But you can pause the VMs yourself from within your script, with a command such as Get-VM | Suspend-VM, before your script does whatever it does that requires that the VMs are paused first.

Just spin and wait for all your VMs to no longer be running before continuing...

While ((Get-VM).State -Contains 'Running') { }

  • Problem with that is that the shutdown script GPO then times out and does not actually shutdown the remote server – NickC May 9 '16 at 19:49
  • Have you considered configuring HKLM\SYSTEM\CurrentControlSet\Services\gpsvc\PreshutdownTimeout and Computer Configuration\Administrative Templates\System\Logon\Maximum wait time for Group Policy scripts ? – BlueCompute May 10 '16 at 11:17

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.