Managing DHCP leases through PowerShell is faster and more efficient than manually navigating the DHCP console. Windows Server provides the DhcpServer PowerShell module to retrieve leases, identify MAC addresses, inspect reservations, check lease expiry, and export DHCP inventory reports.
This guide covers the most useful Windows DHCP Server PowerShell commands, from checking a single IP address to auditing an entire DHCP scope.
1. Prerequisites
Run PowerShell as an administrator on the DHCP server or a management computer with the DHCP Server PowerShell tools installed.
For a remote DHCP server, use the appropriate server name in the commands below.
Import-Module DhcpServer
Set the DHCP server and scope details as variables to simplify repeated commands.
$DHCPServer = "DHCP01.contosa.com"
$ScopeId = "10.102.12.0"
Replace these sample values with your actual DHCP server name and subnet ID.
2. Find DHCP Lease Details for a Particular IP Address
Use this command to retrieve the hostname, client identifier, lease state, and expiry time for a specific IP address.
Get-DhcpServerv4Lease -IPAddress 10.102.12.12 |
Format-List IPAddress, HostName, ClientId,
AddressState, LeaseExpiryTime
Use case: Identify which hostname and client identifier are associated with an IP address.
To query a specific remote DHCP server:
Get-DhcpServerv4Lease `
-ComputerName $DHCPServer `
-IPAddress 10.102.12.12 |
Format-List *
3. Retrieve All Leases in a Particular DHCP Scope
To list every lease in a scope, including leases that are not currently active:
Get-DhcpServerv4Lease -ScopeId $ScopeId -AllLeases |
Format-Table IPAddress, HostName, ClientId,
AddressState, LeaseExpiryTime -AutoSize
To retrieve only active leases:
Get-DhcpServerv4Lease -ScopeId $ScopeId |
Format-Table IPAddress, HostName, ClientId,
AddressState, LeaseExpiryTime -AutoSize
Use -AllLeases when investigating historical lease states that remain in the DHCP database.
4. Retrieve Leases from Every DHCP Scope
First, list the configured IPv4 scopes.
Get-DhcpServerv4Scope |
Format-Table ScopeId, Name, StartRange,
EndRange, State -AutoSize
Then retrieve leases from all scopes:
$Scopes = Get-DhcpServerv4Scope
$AllLeases = foreach ($Scope in $Scopes) {
Get-DhcpServerv4Lease -ScopeId $Scope.ScopeId -AllLeases
}
$AllLeases |
Format-Table IPAddress, HostName, ClientId,
AddressState, LeaseExpiryTime -AutoSize
For a remote DHCP server:
$Scopes = Get-DhcpServerv4Scope -ComputerName $DHCPServer
$AllLeases = foreach ($Scope in $Scopes) {
Get-DhcpServerv4Lease `
-ComputerName $DHCPServer `
-ScopeId $Scope.ScopeId `
-AllLeases
}
$AllLeases |
Format-Table IPAddress, HostName, ClientId,
AddressState, LeaseExpiryTime -AutoSize
5. Find the MAC Address of a Host
The DHCP ClientId field commonly contains the client’s MAC address.
Get-DhcpServerv4Lease -IPAddress 10.102.12.12 |
Format-List IPAddress, HostName, ClientId
For a particular hostname:
Get-DhcpServerv4Lease -ScopeId $ScopeId -AllLeases |
Where-Object {
$_.HostName -like "IPWWBAAGLMJ20AZ*"
} |
Format-Table IPAddress, HostName, ClientId,
AddressState, LeaseExpiryTime -AutoSize
Important: Not every DHCP client identifier is a conventional six-byte Ethernet MAC address. Some clients use other identifier formats, so verify the value before treating it as a physical MAC address.
6. Find a Host by Its IP Address or Hostname
Search for a particular hostname
Get-DhcpServerv4Lease -ScopeId $ScopeId -AllLeases |
Where-Object {
$_.HostName -like "*SERVER01*"
} |
Format-Table IPAddress, HostName, ClientId,
AddressState, LeaseExpiryTime -AutoSize
Search for a particular client identifier
Get-DhcpServerv4Lease -ScopeId $ScopeId -AllLeases |
Where-Object {
$_.ClientId -eq "5C-ED-8C-F1-31-F0"
} |
Format-List *
Replace the example client identifier with the value returned by your DHCP server. The format of the identifier may vary.
7. Find DHCP Reservations
To list all reservations configured on a particular scope:
Get-DhcpServerv4Reservation -ScopeId $ScopeId |
Format-Table IPAddress, Name, ClientId,
Description -AutoSize
To check a reservation for a specific IP address:
Get-DhcpServerv4Reservation -ScopeId $ScopeId |
Where-Object {
$_.IPAddress -eq "10.102.12.12"
} |
Format-List *
To retrieve reservations from every IPv4 scope:
$AllReservations = foreach ($Scope in Get-DhcpServerv4Scope) {
Get-DhcpServerv4Reservation -ScopeId $Scope.ScopeId
}
$AllReservations |
Format-Table IPAddress, Name, ClientId,
Description -AutoSize
Remember that a reservation and a lease are different. A reservation defines the address assigned to a particular client identifier; the lease records the client’s DHCP address state.
8. Find Expired or Inactive Leases
To inspect leases that are not active, use -AllLeases and filter the returned states.
Get-DhcpServerv4Lease -ScopeId $ScopeId -AllLeases |
Where-Object {
$_.AddressState -ne "Active"
} |
Format-Table IPAddress, HostName, ClientId,
AddressState, LeaseExpiryTime -AutoSize
To identify expired lease entries based on their expiry time:
Get-DhcpServerv4Lease -ScopeId $ScopeId -AllLeases |
Where-Object {
$_.LeaseExpiryTime -and
$_.LeaseExpiryTime -lt (Get-Date)
} |
Format-Table IPAddress, HostName, ClientId,
AddressState, LeaseExpiryTime -AutoSize
This is a reporting query only. An expired lease entry is not necessarily safe to remove manually; first confirm the address is no longer in use.
9. Check Lease Expiry for a Particular Host
Get-DhcpServerv4Lease -IPAddress 10.102.12.12 |
Select-Object IPAddress, HostName, ClientId,
AddressState, LeaseExpiryTime
The LeaseExpiryTime field indicates when the recorded lease expires. It does not establish the original assignment date.
10. Export DHCP Leases to CSV
Export every lease in a particular scope:
Get-DhcpServerv4Lease -ScopeId $ScopeId -AllLeases |
Select-Object IPAddress, HostName, ClientId,
AddressState, LeaseExpiryTime |
Export-Csv "C:\Reports\DHCP-Leases.csv" -NoTypeInformation
Export leases from all scopes:
$AllLeases |
Select-Object IPAddress, HostName, ClientId,
AddressState, LeaseExpiryTime |
Export-Csv "C:\Reports\All-DHCP-Leases.csv" -NoTypeInformation
Ensure the C:\Reports directory exists before running these commands.
CSV reports can be opened in Microsoft Excel for inventory reconciliation, audit reviews, and hostname-to-IP mapping.
11. Search DHCP Audit Logs
Windows DHCP audit logs are commonly stored in:
C:\Windows\System32\dhcp\
Search all available audit logs for a particular IP address:
Get-ChildItem "C:\Windows\System32\dhcp\DhcpSrvLog-*.log" |
Select-String -SimpleMatch "10.102.12.12"
Search for a hostname:
Get-ChildItem "C:\Windows\System32\dhcp\DhcpSrvLog-*.log" |
Select-String -SimpleMatch "IPWWBAAGLMJ20AZ"
DHCP audit logs may contain assignment, renewal, release, and other events. The available event history depends on logging configuration and log retention.
To find the earliest recorded assignment, search all retained logs for the relevant IP and identify the earliest matching assignment event. If older logs have been overwritten, the original assignment date may not be recoverable from the remaining logs.
12. Check DHCP Scope Configuration
Retrieve configuration details for a particular scope:
Get-DhcpServerv4Scope -ScopeId $ScopeId |
Format-List *
Retrieve all configured IPv4 scopes:
Get-DhcpServerv4Scope |
Format-Table ScopeId, Name, StartRange,
EndRange, SubnetMask, State -AutoSize
These commands help identify scope boundaries, subnet masks, and whether scopes are enabled.
13. Check DHCP Scope Statistics
To review the address utilisation of a particular scope:
Get-DhcpServerv4ScopeStatistics -ScopeId $ScopeId |
Format-List *
To retrieve statistics for all scopes:
Get-DhcpServerv4ScopeStatistics
Scope statistics help administrators monitor address availability and identify scopes that may be running low on free addresses.
14. Check DNS for a DHCP Client
DHCP and DNS are separate services. A lease can exist even when the associated DNS record is missing.
Check the forward lookup:
Resolve-DnsName "IPWWBAAGLMJ20AZ.contosa.com" `
-ErrorAction SilentlyContinue
Check the reverse lookup:
Resolve-DnsName "10.102.12.12" `
-Type PTR `
-ErrorAction SilentlyContinue
These commands query DNS. They do not modify DHCP leases or DNS records.
15. Quick Reference
| Requirement | PowerShell command |
|---|---|
| Particular IP lease | Get-DhcpServerv4Lease -IPAddress 10.102.12.12 |
| All leases in a scope | Get-DhcpServerv4Lease -ScopeId $ScopeId -AllLeases |
| All IPv4 scopes | Get-DhcpServerv4Scope |
| Reservations in a scope | Get-DhcpServerv4Reservation -ScopeId $ScopeId |
| Scope statistics | Get-DhcpServerv4ScopeStatistics -ScopeId $ScopeId |
| Search audit logs | Select-String -SimpleMatch "10.102.12.12" |
| Export leases | Export-Csv "C:\Reports\DHCP-Leases.csv" -NoTypeInformation |
Conclusion
PowerShell simplifies DHCP administration by allowing administrators to inspect individual leases, inventory complete scopes, identify client identifiers, review reservations, investigate historical lease activity, and generate CSV reports.
For day-to-day troubleshooting, start with Get-DhcpServerv4Lease. For broader investigations, combine lease queries with reservation details, DHCP audit logs, and DNS lookups.
Operational note: These examples are read-only. Before removing leases, changing reservations, or modifying DNS, validate the client identity and confirm that the address is no longer in use.