Active Directory
banshee/active-directory-collection/active-directory/ssh/
dhcp-failover
The state of each failover relationship of a Windows DHCP Server, by SSH and PowerShell
by banshee1 installation2 versions
v2Latest
Published on October 28, 2026. One naming convention across collections; documentation completed.
// The failover relationships of the DHCP Server of Windows, by SSH: the state of each relationship, as this
// server sees it, its partner and its mode. Out of the state Normal, the two servers no longer share their
// leases, or one serves alone.
// Runs one PowerShell command that only reads, by the cmdlet Get-DhcpServerv4Failover of the DhcpServer
// module, whose objects are those of the WMI class DhcpServerv4Failover that Microsoft documents: Name,
// PartnerServer, Mode (HotStandby, LoadBalance) and State, whose values Microsoft lists: NoState, Normal,
// Init, CommunicationInterrupted, PartnerDown, PotentialConflict, Startup, ResolutionInterrupted,
// ConflictDone, Recover, RecoverWait, RecoverDone. They are returned as Microsoft writes them.
need('protocol:ssh');
per('relationship', 'Failover relationships');
output('state', 'text', array('label' => 'State', 'per' => 'relationship'));
output('partner', 'text', array('label' => 'Partner', 'per' => 'relationship'));
output('mode', 'text', array('label' => 'Mode', 'per' => 'relationship'));
// A relationship goes through Startup and the Recover states on its way back to Normal: three runs let it.
watch.expect('not-normal', 'Failover not normal', 'state', array('critical' => array('Normal'), 'for' => '3 runs'));
watch.missing('missing', 'Failover relationship missing', 'state', array('enabled' => false));
$read = ssh.run("powershell -NoProfile -NonInteractive -Command \""
. "$ErrorActionPreference = 'Stop'; "
. "[Console]::OutputEncoding = New-Object System.Text.UTF8Encoding; "
. "ConvertTo-Json -Compress -Depth 4 -InputObject @{"
. "relationships = @(Get-DhcpServerv4Failover | ForEach-Object {"
. " @{name = $_.Name; state = [string]$_.State; partner = $_.PartnerServer; mode = [string]$_.Mode} })}\"");
$answer = text.trim($read['output']);
if (list.count(text.match($answer, '^\{')) == 0) {
fail('misconfigured', 'PowerShell did not return the DHCP failover relationships', $answer . $read['errors']);
}
$failover = json.read($answer);
$relationships = 0;
foreach ($failover['relationships'] as $relationship) {
$relationships = $relationships + 1;
value('state', $relationship['state'], $relationship['name']);
value('partner', $relationship['partner'], $relationship['name']);
value('mode', $relationship['mode'], $relationship['name']);
}
if ($relationships == 0) {
fail('misconfigured', 'The DHCP Server has no failover relationship', $answer);
}