VMM Error 25122

This error can occur after manually adding a Hyper-V cluster to VMM 2012 R2. It appears to occur because the Cluster Virtual IP address exists in the IP pool

 

VMM 25122

The script is below, credits to vNikkas who has also blogged about this (there was another version floating around last year too I believe).

$ID = Enter the ID found in the error message (you can copy the text, paste into notepad and then copy the ID

$IPPoolName = Enter the name of the IP pool associated with the error message


If (-not (Get-Module virtualmachinemanager)) {
Import-Module virtualmachinemanager }

$IP = Get-SCIPAddress | Where-Object {$_.ID -eq $ID}
$IPPool = Get-SCStaticIPAddressPool -Name $IPPoolName
# Looking up DNS Name based on IP Address
$VMHostClusterName = [System.Net.Dns]::GetHostbyAddress($IP.Name)
$VMHostCluster = Get-SCVMHostCluster -Name $VMHostClusterName.HostName

# Giving the IP Address back to the IP Pool
Get-SCIPAddress -IPAddress $IP | Revoke-SCIPAddress

# Allocating the IP Address to the VM Host Cluster
Grant-SCIPAddress -GrantToObjectType HostCluster -GrantToObjectID $VMHostCluster.ID -IPAddress $IP.Name -StaticIPAddressPool $IPPool -Description $VMHostCluster.Name