PS without BS: Extracting DHCP Reservations to a CSV


Just a quick snippet that shows how to extract existing reservations into a text file using PowerShell and Windows Server. Some have a need to export a list of IP addresses into a CSV file that you can quickly drop into Excel.

For those wondering, yes, I like using active DHCP reservations for all my servers, except domain controllers and Hyper-V hosts. It just makes things so much easier and consistent to configure.

That being said, the following PowerShell should do the trick...

Get-DHCPServerV4Scope | ForEach {
Get-DHCPServerv4Lease -ScopeID $_.ScopeID | where {$_.AddressState -like '*Reservation'}
} | Select-Object ScopeId,IPAddress,HostName,ClientID,AddressState | Export-Csv ".\$($env:COMPUTERNAME)-Reservations.csv" -NoTypeInformation

Your output will look like this...
"ScopeId","IPAddress","HostName","ClientID","AddressState"
"10.0.1.0","10.0.1.10","client1.domain.com","00-15-5d-01-81-09","ActiveReservation"
"10.0.1.0","10.0.1.11","client2.domain.com","00-15-5d-01-6e-16","ActiveReservation"

Happy scripting.

-- If you like my blogs, please share it on social media, rate it, and/or leave a comment. --


Comments (0)

Skip to main content