How to fix the issue “KB2920189 fails to install on generation 2 virtual machines” in Windows Server 2012 R2 (PowerShell)
Introduction
This script shows how to fix the issue “KB2920189 fails to install on generation 2 virtual machines” in Windows Server 2012 R2.
Scenarios
Some IT Admins encounter an issue that KB2920189 fails to install on generation 2 virtual machines in Windows Server 2012 R2. This script is to fix that issue.
Script
Step 1: Run PowerShell with administrator and use the script like the following.

Step 2: Then there will be a dialog like the following. You need to login all virtual machines and check for update. After that, press enter to continue.

Note Please make sure that all virtual machines’ data have been saved. This script will turn off all VMs and restart them.
Here are some code snippets for your references
PowerShellEdit|Removepowershellforeach($vm in $vmcol) { if($vm.State -eq "Running") { Stop-VM $vm -TurnOff } ElseIf($vm.State -eq "Saved") { Start-VM $vm Stop-VM $vm -TurnOff } Set-VMFirmware $vm -EnableSecureBoot Off Start-VM $vm }foreach($vm in $vmcol) { if($vm.State -eq "Running") { Stop-VM $vm -TurnOff } ElseIf($vm.State -eq "Saved") { Start-VM $vm Stop-VM $vm -TurnOff } Set-VMFirmware $vm -EnableSecureBoot Off Start-VM $vm }
Prerequisite
Windows Server 2012R2