Posted On January 25, 2023

Resume All Guest VMs in a Clustered Hyper-V Environment

kimconnect 0 comments
blog.KimConnect.com >> Virtualization , Windows >> Resume All Guest VMs in a Clustered Hyper-V Environment
# resumeAllVms.ps1
# Significance: this script is useful in a Clustered Hyper-V environment
# where storage was down for over 60 seconds, causing Hyper-V to put all guest VM's into 'paused-critical' statuses.
# During such event, the cluster would be unreachable as well. Hence, knowing node names prior to pasting this script
# would be necessary.

$computerlist=@'
hyperVServer1
hyperVServer2
hyperVServer100
'@
$computernames=@($computerlist -split "`n")|%{$_.Trim()}
foreach ($computername in $computernames){
  invoke-command $computername {
    write-host "Connected to $env:computername..."
    #Get list of all VMs on this host
    #$vmNames=(get-vm).Name
    #write-host "$env:computername`:`r`n$($vmNames|out-string)"
    
    # Unpausing all VMs
    $pausedVms=get-vm | where state -eq 'paused'
    foreach($vm in $pausedVMs){        
        write-host $vm.Name -nonewline
      try{        
        $vm|resume-vm -ea stop
        write-host ": resumed" -foregroundcolor Green
      }catch{
        write-warning $_
        continue
      }    
    }   
  }
}

Leave a Reply

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

Related Post

HPE: Gen8 Bios Settings to Prepare Host for Virtualization Role

Proliant Gen8 Blade Servers HP Servers are often chosen as VMWare & Hyper-V hosts. To…

PowerShell: Fix All VMs CPU Compatibility Setting

# fixAllVmCpuCompatibility.ps1 # version 0.01 function getHyperVHostsInForest{ function includeRSAT{ $ErrorActionPreference='stop' [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 #$rsatWindows7x32='https://download.microsoft.com/download/4/F/7/4F71806A-1C56-4EF2-9B4F-9870C4CFD2EE/Windows6.1-KB958830-x86-RefreshPkg.msu' $rsatWindows7x64='https://download.microsoft.com/download/4/F/7/4F71806A-1C56-4EF2-9B4F-9870C4CFD2EE/Windows6.1-KB958830-x64-RefreshPkg.msu'…

Projects for Mystery Client in 2005

Mystery Client Technology Overview Last year Mystery Client upgraded to Microsoft Exchange 2003. This had…