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...

Happy scripting.

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