PowerShell with Windows DHCP Quick Win

Keep calm and import module dhcpserver

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!


VMworld Wednesday Lessons Learned

One of the strengths of a conference such as VMworld is being able to direct questions to strangers across the table at meals and often get a useful answer.  At lunch Wednesday I struck up a conversation with the folks at the table about PowerCLI to see if I could accomplish this task:
3. Learn some basic functions of PowerCLI
It turns out they were easily able to get me pointed in the right direction.  PowerCLI is an application available for download from VMware that an administrator can run on their workstation to help with mundane and repetitive tasks related to vSphere management.  PowerCLI is a VMware tool that is based on Microsoft’s PowerShell which is available on most (or all?) modern Windows OS versions.  PowerGUI, as the name suggests, is a free graphical front-end for PowerShell that can incorporate components to managed vSphere.  One of the top 10 VMworld sessions this year was “VSVC4944: PowerCLI Best Practices: A Deep Dive” (available on YouTube here)
I attended “Key Lessons Learned from Deploying a Private Cloud Service Catalog” (OPT5051), presented by two consultants from Greenpages Technology Solutions that implemented such a system for one of their customers. In their case study, five people spent 6-8 months working with their corporate customer building consensus between different groups within the company for what should be in the service catalog, what could be automated, and what things were deemed too complicated and would take too much effort to implement in the initial engagement.
They initially started the project by gathering all requirements up front and attempted to implement, but because there was so much “mission creep” after they completed some initial integrations they modified their approach to use individual “Sprints” of 2-3 weeks to build functionality incrementally.
The idea of having a service catalog implies the use of on-demand procurement by end-users. Setting up such a system inevitably leads to higher demand, so the system should have usage monitoring in place. When the available pools drops below a certain threshold, it should be agreed in advance that IT will procure new resources either for the internally based “private cloud” or to be able to take advantage of “hybrid cloud” technology such as VMware’s recently announced vCloud Hybrid Service (vCHS).
Service catalog offerings are meant to provide on-demand service, but it’s important to include financial management tools that will track costs and either “show-back” or “bill-back” the costs to the lines of business using the service.
Finally, I was able to complete the NSX hands-on lab. Not surprisingly, this particular lab was the most taken lab of the week with about 6500 sittings.  Of course, the NSX lab was so long it required 2 sittings, but it’s still impressive that over 3000 people presumably took that lab.
NSX Lab Stats