How to Create a Microsoft DHCP Lease Inventory Script

ipswitchLarge organizations typically have lots of devices that require IP addresses. Client desktops, tablets, mobile and desk phones, servers and more all consume IPs. The only way to manage IPs at this level is to use Microsoft Dynamic Host Configuration Protocol (DHCP), which will also manage which devices obtain which IPs through DHCP leases. Even though the DHCP server in Microsoft Windows handles the majority of the work for you, you’ll occasionally need to run reports and query the current status of a device’s DHCP lease across multiple DHCP servers and scopes.

In this article, I’ll show you how to create a script in PowerShell that will allow you to discover all Microsoft DHCP servers in an Active Directory (AD) domain, all scopes on all of those servers and all leases inside those scopes. This will provide you with a simple way to run point-in-time DHCP lease reports and to easily query all DHCP leases in your organization for leases matching specific criteria.

Getting Started

  • Before we get started, I’m going to assume a few things:
  • You have PowerShell v4+ installed on the computer on which you’re running the script
  • Your computer is in an Active Directory domain
  • You have the Remote Server Administration tools package installed with the DHCP server module enabled
  • You have all the appropriate rights to enumerate DHCP leases in your environment

Read the full article at Ipswitch.

Adam Bertram

Chief Automator at Adam the Automator, LLC
Adam Bertram is an independent consultant, technical writer, trainer and presenter. Adam specializes in consulting and evangelizing all things IT automation mainly focused around Windows PowerShell. Adam is a Microsoft Windows PowerShell MVP, 2015 powershell.org PowerShell hero and has numerous Microsoft IT pro certifications. He authors IT pro course content for Pluralsight, is a regular contributor to numerous print and online publications and presents at various user groups and conferences.You can find Adam here on the blog or on Twitter at @adbertram.

Latest posts by Adam Bertram (see all)

Leave a Reply