Export DHCP Leases to readable CSV RRS feed

  • Question

  • Hi All

    We have multiple DHCP Servers across geographical locations within our environment (All Server 2012 R2). We are looking to deploy MAC filtering as an additional level of security, but want to manage a central Allow list which will be the same across all DHCP servers once this has been deployed. This is so that mobile users we have who roam around sites, would be able to connect seamlessly at each site that they go to.

    To do this, we are going to use the inbuilt IPAM feature and simply update the Allow list on all managed DHCP servers in one go via the IPAM console. However, we need to import the current DHCP leases into the Allow list before we enable it.

    I have read multiple threads on how to export the current leases (netsh/powershell scripts etc), however, each one that I have tried exports the data to file, but not in a very user-friendly readable format.

    Either directly from the server, or from RSAT Admin console for DHCP (unable to post screenshots as my account is not yet verified) you can simply select more actions, and export list to CSV. This file is in a user-friendly readable format.

    Does anyone know if there is a script or command that I can run which mimics this manual export of DHCP leases into the same format? If so, I would then like to run this as a scheduled task and export the DHCP lease list daily over a period longer than the lease period for each site so I can have a more comprehensive list of devices to place into my allow list before enabling MAC filtering.

    Monday, April 30, 2018 11:25 AM


  • Used the following script and set up to run nightly in Task Scheduler to export the data I required in a readable format:

    Get-DhcpServerv4Lease -ComputerName "" -ScopeId x.x.x.x | select Hostname, ClientId, IPAddress | Export-csv -path "\\UNC\filename_$((Get-Date).ToString('MM-dd-yyyy_hh-mm-ss')).csv"

    • Marked as answer by Jonny Hill Tuesday, May 29, 2018 8:37 AM
    Tuesday, May 29, 2018 8:37 AM

All replies