Synchronize MAC address database between Windows 2012 DHCP Server

By | August 13, 2014

In Windows Server 2012, Microsoft added DHCP failover feature. However, this feature will not replicate MAC filter lists (Allow/Deny). Below script is to synchronize DHCP MAC filter database. Link to original post:

Paste below script in Powershell ISE

[code language=”powershell”]
$MasterServerHostname = "MasterDHCPFQDN";

# Get the LOCAL filters from localhost
$lfilters = Get-DhcpServerv4Filter

# Get the REMOTE filters from $MasterServerHostname
$rfilters = invoke-command -computername $MasterServerHostname { Get-DhcpServerv4Filter }

# Delete the local Filter Set
#ForEach ($filter in $rfilters) {
# Remove-DhcpServerv4Filter -MacAddress $filter.MacAddress

# Import the new Filter Set
ForEach ($filter in $rfilters) {
write-host $filter.List
write-host $filter.MacAddress;
write-host $filter.Description
Add-DhcpServerv4Filter -List $filter.List -Force -MacAddress $filter.MacAddress -Description $filter.Description

Script to check number of MAC address record, to ensure all DHCP servers having the same number (optional)
[code language=”powershell”]del C:\MAC\LocalMacList.txt
Get-DhcpServerv4Filter -List Allow > C:\MAC\LocalMacList.txt
Get-Content C:\MAC\LocalMacList.txt | Measure-Object[/code]