Here is a PowerShell script that might help to release expired leases.
which can sometimes free up IP addresses in a scope:
# Import the DHCP module
Import-Module DhcpServer
# Define the DHCP server and scope you want to work with
$DHCPServer = "YourDHCPServerName"
$ScopeID = "YourScopeID" # e.g., 192.168.1.0
# Get the DHCP server
$Server = Get-DhcpServerInDC -ComputerName $DHCPServer
# Get a list of expired leases in the specified scope
$ExpiredLeases = Get-DhcpServerv4Lease -ComputerName $DHCPServer -ScopeId $ScopeID | Where-Object { $_.LeaseExpiry -lt (Get-Date) }
# Release the expired leases to free up IP addresses
foreach ($Lease in $ExpiredLeases) {
$IPAddress = $Lease.IPAddress
Write-Host "Releasing lease for $IPAddress"
Remove-DhcpServerv4Lease -ComputerName $DHCPServer -IPAddress $IPAddress -ScopeId $ScopeID
}
# Close the DHCP server
$Server.Close()
Write-Host "Expired leases released."
And here is a PowerShell script to identify if you have rogue clients (which I suspect you have)
# Import the DHCP module
Import-Module DhcpServer
# Define the DHCP server and scope you want to work with
$DHCPServer = "YourDHCPServerName"
$ScopeID = "YourScopeID" # e.g., 192.168.1.0
# Get a list of all DHCP leases in the specified scope
$AllLeases = Get-DhcpServerv4Lease -ComputerName $DHCPServer -ScopeId $ScopeID
# Create a dictionary to store MAC addresses and associated IP addresses
$MACAddressIPDictionary = @{}
# Iterate through the leases and identify MAC address duplicates
foreach ($Lease in $AllLeases) {
$MACAddress = $Lease.ClientID
$IPAddress = $Lease.IPAddress
if ($MACAddressIPDictionary.ContainsKey($MACAddress)) {
$MACAddressIPDictionary[$MACAddress] += ", $IPAddress"
} else {
$MACAddressIPDictionary[$MACAddress] = $IPAddress
}
}
# Identify MAC addresses with multiple associated IP addresses
$RogueMACAddresses = $MACAddressIPDictionary | Where-Object { $_.Value -match "," }
# Print out MAC addresses and associated IP addresses for potential rogue clients
foreach ($MACAddress in $RogueMACAddresses.Keys) {
Write-Host "Potential Rogue Client MAC Address: $MACAddress"
Write-Host "Associated IP Addresses: $($RogueMACAddresses[$MACAddress])"
}