PowerShell GUI : Releasing Multiple Stale IP’s from DHCP Scope at once.

SCENARIO : Multiple stale IP Addresses for clients no longer connected to the network are occupying the DHCP scope and Clients aren’t able to request free IP Leases.


  1. Reduce the lease duration to something below than Default 8 Days, so that stale IP’s could be auto deleted
  2. Increasing the DHCP Scope Size to accommodate new client requests.
  3. Delete IP addresses that are disconnected from network and free some Scope IP Addresses

We would be focussing on the Third solution here in our script, because it sounds more feasible, quick and effective.

IDEA : Use the DHCPServer Powershell module to query the IP Addresses of a Scope and check if they are responding to Ping requests, if not delete those IP’s from Scope to free some space.


  1. Import the DHCPServer PowerShell module to your machine from a Windows 2012 server with DHCP role installed on it, which by default has the DHCP Module.

    NOTE : Please note this DHCP server is from which we’re importing the Powershell Module onto our machine, not the DHCP server from which IP addresses would be deleted.

  2. When you run the script the it will prompt you for DHCPServer to pull the powreshell modules from.


  3. You will be prompted for your Domain Credential to access the server to import DHCP module.


  4. Once you feed in your domain credentials and hit enter it will download the Powershell module onto your machine from the Win 2012 DHCP server you mentioned in above step. Using the Import-Mdolue Cmdlet like below –
    Import-Module -PSSession (New-PSSession -ComputerName $DHCPServer -Credential Get-Credential ) -Name dhcpserver


  5. Once download is complete, user will be prompted for Information like target DHCP Server, Scope ID and Count of IP’s to be deleted.
  6. Click OK, to proceed
  7. A Summary form will appear, which will summarize the details you mentioned in Previous step and the script will check for stale IP Addresses from the DHCP Scope


  8. Once stale IP’s are identified, they would be listed and you will be prompted to Choose or decline the deletion of these IP’s from the scope.


  9. You can Due diligently check IP’s and Host names to be deleted from the scope and click OK Button.
  10. Stale IP’s will be deleted at once and a log file would be generated like in the below screenshots.



GET THE SCRIPT : Click here to go to my GitHub gist to get the code.

Hope you find it useful. Happy Reading Fellas 🙂


2 thoughts on “PowerShell GUI : Releasing Multiple Stale IP’s from DHCP Scope at once.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s