StevensNet.com

...Because someone's gotta tell the story...

Blogs

To return to the main Blog List, click Full Blog Listing.

Tags

PowerShell

Extracting Reservations from a DHCP Scope

Wednesday, August 24, 2016 in Powershell (Views: 1345)
Just a quick blog to discuss how to extract existing reservations into a text file using PowerShell and Server 2012/R2.

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.30","client1.domain.com","00-15-5d-01-81-09","ActiveReservation"
"10.0.1.0","10.0.1.31","client2.domain.com","00-15-5d-01-6e-16","ActiveReservation"


Happy scripting.

 

Related Blogs You May Be Interested In:


To leave a comment, please log in and/or register.