Tuesday, 27 January 2026

powershell command to check if mac address has a lease and/or reservation

check if mac address has a lease and/or reservation 

You can add more mac's to the list as needed.

I needed this to compare two independent DHCP scopes


$macs = @("xx-xx-xx-xx-yy-yy","zz-zz-zz-zz-zz-zz"); 

$macs | ForEach-Object { 

    $lease = Get-DhcpServerv4Lease -ScopeId 192.168.1.0 -ClientId $_ -ErrorAction SilentlyContinue; 

    $reservation = Get-DhcpServerv4Reservation -ScopeId 192.168.1.0 -ClientId $_ -ErrorAction SilentlyContinue; 

    "MAC: $_, Lease: $($lease.IPAddress -join ', '), Reservation: $($reservation.IPAddress -join ', ')"

}


No comments:

Post a Comment