Recently I needed to check the lease duration for about 25 DHCP scopes on a Windows 2012 server. I’m not a PowerShell guru but I knew there must be an easier way than clicking myself to death. By the miracle of social networking, and thanks to the awesomely-smart Blake Krone, a single command worked for me:
PS C:\Users\swack> Get-DhcpServerv4Scope -ComputerName mydhcpserver-prd1
The output was a table with the following column headers:
- ScopeId (basically the subnet)
- SubnetMask
- Name
- State (Active or Inactive)
- StartRange
- EndRange
- LeaseDuration (looks like format is either HH:MM:SS or D.HH:MM:SS where D=days)
In hindsight, I did a quick search for the command name and found a great post over at Windows OS Hub.
One of the other tricks I had to learn on my own was that the command wouldn’t work on my workstation nor on the DHCP server itself, but it did work on the domain controller. I think it may have to do with a missing PowerShell module (DHCPServer) but that also I couldn’t get to install, even with the commands I was finding through Google.
I’d love to hear your experience with this command, or any cool scripts you’ve written or found in your travels. Drop me a note on Twitter (@swackhap) or add a comment below. Thanks!