Use PowerShell to Determine When Your DHCP Lease Expires

This blog post applies to only Windows 8 and Windows Server 2012. Want to know how much time there is until your current DHCP leases expire?

Get-NetIPAddress -PrefixOrigin Dhcp |
select InterfaceAlias , IPAddress, ValidLifetime

I have 23 hours, 47 minutes, and 46 seconds until my current DHCP lease expires on one of my network interfaces and 22 seconds more than that left on the other one.

dhcp-lease-time01.jpg

Want to know the exact date and time of when they expire?

Get-NetIPAddress -PrefixOrigin Dhcp |
select InterfaceAlias, IPAddress,
@{l="DHCP Expiration";e={(Get-Date).addticks($_.ValidLifetime.ticks)}}

dhcp-lease-time05.jpg

I haven’t added any error handling to these scripts so if DHCP is not enabled on any of your network interfaces, the scripts will generate errors.

ยต