Resolving Guest Virtual Machine Critical Status in Hyper-V Manager

Part A: Validating problem as VM in Critical Status

# Check VM Status in Hyper-V
get-vm $vmName

# Sample output
Name                      State       CPUUsage(%) MemoryAssigned(M) Uptime   Status
----                      -----       ----------- ----------------- ------   ------     OffCritical 0           0                 00:00:00 Cannot connect to virtual machine confi...

# Check storage locations
Get-VM $vmName | fl *Location, Path

# Sample output
CheckpointFileLocation : \\NAS\VMS\
ConfigurationLocation  : \\NAS\VMS\\config
SnapshotFileLocation   : \\NAS\VMS\
Path                   : \\NAS\VMS\\config

Part B: Refresh Hyper-V Virtual Machine Management Service

# Restart Virtual Machine Management Service from VMM Server
$vmInfo=Get-SCVirtualMachine -Name $vmName
#$badVmConfig=$vmInfo|?{$_.Status -eq 'IncompleteVMConfig'}

function restartService($serviceName){
    $isValidProcess=try{[bool](get-service $serviceName -EA Stop)}catch{$false}
            $process=Start-Process -FilePath powershell.exe -ArgumentList "-Command Restart-Service $serviceName" -PassThru -NoNewWindow
            $process|Wait-Process -Timeout $waitSeconds -ErrorAction Stop
            return $true
            write-warning $_
            $process|Stop-Process -Force
            $processId=(get-process $serviceName).Id
                write-host "Program now forcefully kills PID $processId of process $serviceName"
                $null=$processId|%{taskkill /f /pid $_} # works more reliably than Stop-Process $processName -Force
                Start-Service $serviceName -ErrorAction Ignore
                $started=$(try{get-service $serviceName}catch{$false})
                    write-host "'serviceName' status is now $($started.Status)"
                    return $true
                    write-warning "'serviceName' status is $($started.Status)"
                    return $false
                write-warning "Service '$serviceName' PID not found."
                return $false         

$currentHosts|%{invoke-command -computername $_ {param($restartService,$serviceName);write-host "$env:computername";[scriptblock]::create($restartService).invoke($serviceName)}} -Args ${function:restartService},'vmms'

Part C: Guest VM shows as online

# Checking VM while login to Hyper-V Host
PS C:\Windows\system32> get-vm $vmName
get-vm : Hyper-V was unable to find a virtual machine with name "".
At line:1 char:1
+ get-vm $vmName
+ ~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidArgument: ( [Get-VM], VirtualizationException
    + FullyQualifiedErrorId : InvalidParameter,Microsoft.HyperV.PowerShell.Commands.GetVM

# Checking VM while login to VMM
PS C:\Windows\system32> (Get-SCVirtualMachine -Name $vmName).VMHost.FullyQualifiedDomainName
HYPERV07 (bad record)

# Find bad VM config on VMM Server
$vmInfo=Get-SCVirtualMachine -Name $vmName
$badVmConfig=$vmInfo|?{$_.Status -eq 'IncompleteVMConfig'}

# Example of failed repair
Repair-SCVirtualMachine : This action is not valid because virtual machine is in state
Incomplete VM Configuration. The repair action can only be used on a virtual machine in a failed state. (Error ID: 693)

At line:1 char:1
+ Repair-SCVirtualMachine -VM $badRecord -Retry
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : ReadError: (:) [Repair-SCVirtualMachine], CarmineException
    + FullyQualifiedErrorId : 693,Microsoft.SystemCenter.VirtualMachineManager.Cmdlets.RepairVmCmdlet

PS C:\Windows\system32> refresh-vm $badRecord
refresh-vm : An internal error has occurred trying to contact the 'HYPERV01' server: NO_PARAM: NO_PARAM.
WinRM: URL: [http://HYPERV01:5985], Verb: [ENUMERATE], Resource:
[], Filter: []
 (Error ID: 2912, Detailed Error: The requested resource is in use (0x800700AA))

Check that WS-Management service is installed and running on server 'HYPERV01'. For more information
use the command "winrm helpmsg hresult". If 'HYPERV01' is a host/library/update server or a PXE server
role then ensure that VMM agent is installed and running. Refer to for more

To restart the job, run the following command:
PS> Restart-Job -Job (Get-VMMServer localhost | Get-Job | where { $_.ID -eq "{26ce1506-da92-42a7-a400-705fe1008188}"})
At line:1 char:1
+ refresh-vm $badRecord
+ ~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : ReadError: (:) [Read-SCVirtualMachine], CarmineException
    + FullyQualifiedErrorId : 2912,Microsoft.SystemCenter.VirtualMachineManager.Cmdlets.RefreshVmCmdlet

Leave a Reply

Your email address will not be published. Required fields are marked *