Force Reboot Remote Cluster Node

Purpose: Sometimes a Hyper-V Failover Cluster node does not want to shut down, or is having issues preventing you from migrating VMs to another node in the cluster, etc. In these situations, you can run this script to force a cluster node to reboot itself.

Run from a Different Server

You absolutely do not want to run the script locally on the node that is having the issues. There are commands that can only take place if the script is ran on another node in the cluster (or another domain-joined device) logged-in with a domain administrator account.

# PowerShell Script to Reboot a Hyper-V Failover Cluster Node and Kill clussvc

# Prompt for the hostname
$hostName = Read-Host -Prompt "Enter the hostname of the Hyper-V Failover Cluster Node"

# Output the step
Try{
    Write-Host "Sending reboot command to $hostName..."
    # Send the reboot command
    Restart-Computer -ComputerName $hostName -Force -ErrorAction Stop
}
Catch{
    Write-Host "Reboot already in queue"
}

# Output waiting
Write-Host "Waiting for 120 seconds..."

# Wait for 120 seconds
Start-Sleep -Seconds 120

# Output stoping clussvc
Write-Host "Checking if Cluster Service needs to be stopped"

# Kill the clussvc service
Invoke-Command -ComputerName $hostName -ScriptBlock {
    try {
        $service = Get-Service -Name clussvc
        $process = Get-Process -Name $service.Name
        Stop-Process -Id $process.Id -Force
    } catch {
        Write-Host "Error stopping clussvc: $_"
    }
}

# Output the step
Write-Host "Waiting for 60 seconds..."
Start-Sleep -Seconds 60

# Kill the VMMS service
Invoke-Command -ComputerName $hostName -ScriptBlock {
    try {
        $service = Get-Service -Name vmms
        $process = Get-Process -Name $service.Name
        Stop-Process -Id $process.Id -Force
    } catch {
        Write-Host "Error stopping VMMS: $_"
    }
}

# Output the completion
Write-Host "Reboot for $hostName should now be underway."