On this page
What KB 3058418 actually says
Microsoft's article, originally KB 3058418 and now on Microsoft Learn, describes a Windows Server 2012 R2 host with the Hyper-V role, on a UPS or a laptop battery. The battery runs down, Windows shuts the host down because of the low battery condition, and after the restart the VMs are Stopped. The configured stop actions "(Stop VM, Save VM state, Shut down VM) don't run as expected, and the virtual machines are not gracefully shut down or saved."
Microsoft's stated cause
"When a shutdown is triggered by a low battery (either Low or Critical levels), services that are running on the system are not notified of the shutdown. This behavior occurs because a clean operating system shutdown is prioritized over stopping services, as stopping services can block shutdowns for a lengthy period. Because Hyper-V relies on service notifications to trigger the configured actions on the guest VMs, the configured actions don't run before the host shuts down."
The service in question is the Virtual Machine Management Service. A 2008 Microsoft blog post on the first Hyper-V release explains the mechanism: VMMS registers for preshutdown notifications, and when it receives one it "fires the shutdown action on all of the active virtual machines" and waits for them to reach that state. A battery-triggered shutdown skips that notification, so VMMS never acts. The evidence Microsoft lists is Event ID 18590 in the host's Hyper-V-Worker-Admin log (a fatal guest error, code 0xEF) and Event ID 6008 inside the guest ("The previous system shutdown ... was unexpected").
The same article gives the way out. Its note says the behavior "does not apply when the system is shut down by third-party UPS software," and its resolution is to use the UPS manufacturer's software "to correctly handle battery threshold levels and to initiate a regular system shutdown."
Why the two answers both circulate
One camp says "set the Automatic Stop Action and Hyper-V handles it." Another says "the VMs crash on a power cut no matter what you set." Both are describing real hosts. The first is true whenever Windows shuts down normally, from the Start menu, shutdown /s or UPS software. The second is true when the trigger is Windows' own battery setting, the one our Windows UPS shutdown guide recommends for an ordinary PC. A Hyper-V host is the one machine where that built-in setting is the wrong tool.
Does it still happen on Server 2016, 2019, 2022 or 2025?
Nobody has published an answer. We re-read the Microsoft article on 28 October 2026: it was revised on 12 February 2026, and its scenario still names only Windows Server 2012 R2 (the page summary mentions Windows Server 2012 and Windows 8). It does not say later versions are fixed, and it does not say they are affected. No other Microsoft page we found addresses it.
That gap decides the advice. Because the article confirms that UPS software is unaffected, using UPS software is the safe choice on every version. Whether the built-in battery action works on your build is something only a pull-the-plug test with the event logs above can tell you, and it is not worth betting your guests on.
Pick the trigger: which UPS software for your setup
| UPS connection | Run on the Hyper-V host | Notes |
|---|---|---|
| APC with a Network Management Card | PowerChute Network Shutdown, configured for Hyper-V | Can shut VMs down itself, with per-group durations; handles failover clusters and SCVMM |
| APC or CyberPower on USB to the host | The vendor's locally connected edition; see PowerChute and PowerPanel | Starts a regular Windows shutdown; relies on the Hyper-V stop actions below |
| APC on USB, no vendor software wanted | apcupsd, which lists Win32 among its platforms | Mature but last released as 3.14.14 in February 2022 |
| Any brand, UPS owned by a NAS, firewall or Linux box running NUT | WinNUT-Client, or NUT's own Windows binaries (2.8.5-1 is the current release archive) | Set the trigger to shutdown, never suspend |
| UPS card speaks SNMP only | A NUT server with snmp-ups elsewhere, then a client on the host | See network cards and SNMP |
Whichever you choose, keep the Windows critical battery action, but set its level low (a few percent) so it only fires if the UPS software has failed. Two programs racing at similar thresholds is how a host ends up on the battery-triggered path after all. And if a NAS or Linux box owns the UPS, the host gets its signal over the network, so the switch between them must be on a battery outlet too. A Synology NAS is a common NUT server for this.
Set the stop and start actions with Set-VM
UPS software shuts down Windows. What happens to each running VM at that moment is still decided by its own Hyper-V settings. Microsoft's Set-VM reference lists them:
| Parameter | Values | What it controls |
|---|---|---|
-AutomaticStopAction | TurnOff, Save, ShutDown | What the VM does "when the virtual machine host shuts down" |
-AutomaticStartAction | Nothing, StartIfRunning, Start | What the VM does when the host starts |
-AutomaticStartDelay | Seconds | How long the VM's start is held back after the host starts |
New VMs default to Save. ShutDown relies on the guest's shutdown integration service: APC's PowerChute guide states that each VM "must have Integration Services installed with Operating system shutdown enabled" for a graceful shutdown. Check every VM first, then set them:
# List what each VM will do, and how much memory a Save would write
Get-VM | Select-Object Name, State, AutomaticStopAction,
AutomaticStartAction, AutomaticStartDelay,
@{n='MemoryGB';e={[math]::Round($_.MemoryAssigned/1GB,1)}}
# Confirm the guest shutdown service is on
Get-VMIntegrationService -VMName * -Name Shutdown |
Select-Object VMName, Enabled, PrimaryStatusDescription
# Shut down cleanly on host shutdown; come back in dependency order
Set-VM -Name DC01 -AutomaticStopAction ShutDown -AutomaticStartAction Start -AutomaticStartDelay 0
Set-VM -Name SQL01 -AutomaticStopAction ShutDown -AutomaticStartAction Start -AutomaticStartDelay 90
Set-VM -Name APP01 -AutomaticStopAction ShutDown -AutomaticStartAction Start -AutomaticStartDelay 180
Set-VM -Name LAB01 -AutomaticStopAction ShutDown -AutomaticStartAction Nothing
Changing a VM away from Save also frees the disk space Hyper-V reserves for its memory, which Jaap Wesselius found was filling the system disk of a Server 2016 lab host.
Stop-VM first, when order matters
There is no stop order in Set-VM. As Microsoft described VMMS, it fires the stop action on all active VMs together, which is fast, but it means an application server and the database it writes to stop at the same moment. Unlike ESXi's autostart list or Proxmox's start/shutdown order, Hyper-V gives you no setting for this. A script run by the UPS software before the host shutdown does it:
# C:\UPS\stop-vms.ps1 - stop VMs in tiers, front-end first
$tiers = @(
@{ Names = 'APP01','APP02'; Timeout = 180 },
@{ Names = 'SQL01'; Timeout = 240 },
@{ Names = 'DC01'; Timeout = 120 }
)
foreach ($t in $tiers) {
$vms = Get-VM -Name $t.Names -ErrorAction SilentlyContinue |
Where-Object State -eq 'Running'
if (-not $vms) { continue }
$jobs = foreach ($vm in $vms) { Stop-VM -VM $vm -Force -AsJob }
Wait-Job -Job $jobs -Timeout $t.Timeout | Out-Null
# Anything still running after its timeout is turned off
Get-VM -Name $t.Names | Where-Object State -eq 'Running' |
Stop-VM -TurnOff -Force
}
Plain Stop-VM shuts the guest down through its operating system. With -Force, Microsoft says the guest gets "five minutes to save data" if applications hold unsaved data, so keep each tier's timeout under that or accept the hard stop at the end of the loop. In PowerChute Network Shutdown, call it from a command file (powershell.exe -NoProfile -ExecutionPolicy Bypass -File C:\UPS\stop-vms.ps1) and enter the sum of the timeouts, here 540 seconds, in the command file Duration field. VMs not named in the script still get their automatic stop action when Windows goes down.
A timing budget: Shut down vs Save
Because all VMs stop together, the two actions are budgeted differently. Shut down is limited by the slowest guest. Save is limited by the disk: every VM writes its memory at the same time to the same storage.
Take a host with four VMs holding 4, 8, 16 and 32 GB, or 60 GB (61,440 MB) in all, on a UPS whose runtime is 25 to 30 minutes new and 15 to 20 minutes aged, like the 1500 VA unit in our homelab example. PowerChute's On Battery event waits 120 seconds by default, and APC's FAQ FA241713 says PowerChute adds a built-in 2 minutes for the operating system shutdown (10 plus 60 seconds, rounded up).
| Stage | Shut down (s) | Save to SSD at 400 MB/s (s) | Save to HDD array at 150 MB/s (s) |
|---|---|---|---|
| On Battery delay | 120 | 120 | 120 |
| VMs stop (slowest guest, or 61,440 MB / write speed) | 180 | 154 | 410 |
| PowerChute built-in OS shutdown | 120 | 120 | 120 |
| Total | 420 | 394 | 650 |
| With 50% margin, in minutes | 10.5 | 9.9 | 16.3 |
Our runtime guide adds about 50% margin to the shutdown budget. The Shut down plan and the SSD Save plan both fit inside an aged battery's 15 minutes. The HDD Save plan does not: 16.3 minutes is more than the aged runtime, and the battery would run out while VMs are still writing memory. Time your own Save once with Measure-Command { Stop-VM -Name SQL01 -Save } and your slowest clean shutdown with the same wrapper around Stop-VM -Name SQL01, then put the real numbers in the table. The runtime calculator gives the battery side.
Rule of thumb: Save costs memory, Shut down costs patience
Save feels safer because nothing is lost, but its battery cost is fixed by gigabytes of RAM and grows every time someone adds memory to a VM. Shut down costs whatever the slowest guest takes, which you can fix in the guest. On a UPS-protected host, default to ShutDown and keep Save for the one VM you have measured.
PowerChute also checks the budget for you. Per FA241713, it reports "Available runtime has been exceeded" when its total shutdown time is greater than the card's Low Battery Duration minus two minutes, or when the On Battery delay plus that total exceeds the UPS's remaining runtime minus two minutes. If you see that message, the table above is the place to start cutting.
Where this stops applying
- Failover clusters. PowerChute's Stop Cluster option stops the cluster service on every node, and APC's guide says "the running VMs are put in a saved state" when it does, so migration first gains little; APC recommends disabling VM migration when Stop Cluster is on. Budget those nodes as Save, by memory.
- Hyper-V on Windows 10 or 11. The article's scenario includes laptops and its summary mentions Windows 8, so client Hyper-V deserves the same caution: let UPS software trigger the shutdown, not the battery setting.
- Old Save behavior. The 2008 Microsoft post warned that VMMS is terminated if it stops responding to the service manager for 3 minutes, and asked whether a slow Save took longer than that. Later versions are not documented either way; a measured Save time well inside your budget sidesteps the question.
- Restart after the outage. Start actions only matter if the host boots. Set the server's AC power recovery option, and remember PowerChute's default is "Do not turn off the UPS", so the outlets may never cycle. Runtime calibration keeps the runtime figure honest between tests.
Test once in a maintenance window: unplug the UPS from the wall, watch the UPS software start the shutdown, and after the restart check the host and guests for Event IDs 18590 and 6008. Neither should appear.
Frequently asked questions
Does KB 3058418 still apply to Windows Server 2019, 2022 or 2025?
No source says either way. Microsoft's article, last revised in February 2026, still names only Windows Server 2012 R2 in its scenario. It does not say newer versions are fixed, and it does not say they are affected. Treat Windows' own battery-triggered shutdown as untested on any version, and use UPS software instead, which the article says is not affected.
Which automatic stop action should I use on a UPS-protected host?
Shut down for most VMs. It needs the guest's shutdown integration service, and it leaves the VM in a clean Off state that any start action can handle. Use Save only for a VM you cannot shut down quickly and have measured, because Save time grows with memory. Turn off is a power cut for the guest and belongs only on disposable test VMs.
Can WinNUT shut down a Hyper-V host?
Yes, if a NUT server elsewhere (a NAS, a Linux box, a firewall) owns the UPS. WinNUT-Client connects to it and has configurable shutdown and suspend triggers. Choose shutdown, never suspend, on a hypervisor. The project's own README says this version of WinNUT is being retired in favor of a successor, so check its release page before relying on it.
How can I tell whether my VMs were shut down or crashed?
Look in each guest after the test. Microsoft lists Event ID 18590 in the Hyper-V-Worker-Admin log on the host, describing a fatal guest error with code 0xEF, and Event ID 6008, "The previous system shutdown was unexpected", inside the guest. If either appears after a UPS test, the stop actions did not run.
Should the Hyper-V host power itself back on after the outage?
Usually yes, through the server firmware's AC power recovery setting. That only works if the UPS actually cuts and restores its outlets. PowerChute Network Shutdown's default is not to turn off the UPS, so if mains returns before the battery runs out, the outlets never lose power and the host stays off until you enable UPS turn-off or press the button.
Sources and further reading
- Microsoft Learn: VM shutdown actions don't run (original KB 3058418), revised 2026-02-12
- Microsoft Learn: Set-VM (Hyper-V module)
- Microsoft Learn: Stop-VM (Hyper-V module)
- Microsoft TechNet blog archive: Hyper-V: 3 Minute Warning (December 2008)
- Schneider Electric: PowerChute Network Shutdown v5.2 Hyper-V and SCVMM User Guide (990-4595M-001, April 2025)
- Schneider Electric FAQ FA241713: PowerChute Network Shutdown reports "Available runtime has been exceeded"
- Jaap Wesselius: Windows Server 2016 Hyper-V quickly fills up system disk (February 2017)
- NUT Dot Net: WinNUT-Client README and Network UPS Tools download page (Windows binaries)
- apcupsd project page (platforms including Win32, release 3.14.14)