70 How to check the last patch (KB) installed (date and KB number) on each node/host of the Hyper-V cluster?
In the below PowerShell script:-
- Name and save the script as “Get-Cluster_Node_Last_patch_Installed.PS1”.
- Run the script from the PowerShell console.
- Give the “cluster name” as input.
- The output will be displayed on the PowerShell console.
In case of any hurdle, please Contact Us
# Prompt for the Hyper-V cluster name
$clusterName = Read-Host "Enter the Hyper-V cluster name"
try {
# Get the Hyper-V cluster nodes
$clusterNodes = Get-ClusterNode -Cluster $clusterName | Select-Object -ExpandProperty Name
# Create an array to store results
$results = @()
foreach ($node in $clusterNodes) {
try {
# Get information about installed patches
$lastInstalledPatch = Get-HotFix -ComputerName $node | Sort-Object -Property InstalledOn -Descending | Select-Object -First 1
# Add the result to the array
$results += [PSCustomObject]@{
HostName = $node
KBNumber = $lastInstalledPatch.HotFixId
LastInstalledPatch= $lastInstalledPatch.Description
InstallDate = $lastInstalledPatch.InstalledOn
}
} catch {
Write-Host "Failed to retrieve information from $node. Error: $_"
}
}
# Display detailed results in a table
$results | Format-Table -AutoSize
} catch {
Write-Host "Failed to retrieve cluster information. Error: $_"
}