Documenting Microsoft DHCP with Microsoft Word and PowerShell

On a recent project, the customer needed a way to document their DHCP configuration after losing the DHCP database on one of their DHCP servers. I offered to create a script and they gave me permission to do so. Microsoft makes DHCP cmdlets for Windows Server 2012 and higher. The customer had a 2012 DHCP server that was not in production so I used that to create the initial script. They did not have a Windows 8.x computer for me to use so I had to use Microsoft Notepad on the DHCP server to create the script. After creating the initial script, I sent out a request for testers and added a lot more functionality to the script. I received a lot of requests from people wanting to test the script and these people offered a lot of suggestions and enhancements.

Before I get started listing all the features, I want to start by thanking a dedicated and hardworking group of testers and others who provided PowerShell help and guidance for developing this script. This is the list of testers who gave me permission to use their names.

  • Aaron Parker
  • Andrew S. Baker
  • Charles Polisher
  • Daniel Chenault
  • David McSpadden
  • Duy Le
  • Glen Thompson
  • Jorge De Almeida Pinto
  • Kevin James
  • Martin Therkelsen
  • Paul Loonen
  • Roy Textor
  • Ryan Revord
  • Samuel Legrand
  • Timothy “Big Kahuna” Mangan
  • Tyson Leslie

The customer’s original DHCP server that had the database issue was running Windows Server 2003. When I found the PowerShell cmdlets for DHCP, I saw there were Export and Import cmdlets. But when I tried to run the Export cmdlet against the 2003 server, it did not work.

Exporting DHCP from a 2003 DHCP Server

Exporting DHCP from a 2003 DHCP Server

What I found out was that the netsh command worked from Windows Server 2000 all the way up through Server 2012 R2 and is much faster than PowerShell. The PowerShell Export/Import works on Windows Server 2008 and higher but I prefer the netsh commands.

netsh dhcp server export c:\dhcpexport.txt all 

netsh dhcp server import c:\dhcpexport.txt all

The script documents every nook and cranny of both IPv4 and IPv6 that I can find a way to document using PowerShell. Version 1.0 of the script will create a Word, PDF or Formatted Text document named after the DHCP server. For example, 2003DHCP_DHCP_Inventory.docx (or .PDF or .TXT). If the server name is entered as localhost or an IP address, the script will attempt to resolve those to the actual server name. A future update will add an HTML output option.

The following items are documented:

  • DHCP Server Information
    • IPv4
      • Properties
      • General
      • DNS
      • Netword Access Protection
      • Filters
      • Failover
      • Advanced
      • Statistics
    • Superscopes
      • Scopes
        • Address Pool
        • Address Leases
        • Reservations
        • Scope Options
        • Policies
        • DNS
        • Failover
        • Statistics
    • Scopes
      • Address Pool
      • Address Leases
      • Reservations
      • Scope Options
      • Policies
      • DNS
      • Failover
      • Statistics
    • Multicast Scopes
      • General
      • Lifetime
      • Exclusions
      • Address Leases
      • Statistics
    • BOOTP Table
    • Server Options
    • Policies
    • Filters
      • Allow
      • Deny
    • IPv6
      • Properties
        • General
        • DNS
        • Advanced
        • Statistics
      • Scopes
        • General
        • DNS
        • Lease
        • Address Leases
        • Exclusions
        • Reservations
      • Scope Options
      • Statistics
      • Server Options

Please let me know if I missed documenting any DHCP feature or if something is not documented properly, especially in the IPv6 section.

NOTE: All scripts are continually updated. You can always find the most current versions by going to http://carlwebster.com/where-to-get-copies-of-the-documentation-scripts/

Thanks

Webster

, , , , ,

About Carl Webster

Webster is an independent consultant in the Nashville, TN area and specializes in Citrix, Active Directory and Technical Documentation. Webster has been working with Citrix products for many years starting with Multi-User OS/2 in 1990.

View all posts by Carl Webster

4 Responses to “Documenting Microsoft DHCP with Microsoft Word and PowerShell”

  1. Barry Schiffer Says:

    @Martin great way to enter a great community!

    Like Iain said , put up or shut up. Don’t like the script write your documentation manually. If anything Carl is always listening and learning fromconstructive critiscm.

    Reply

  2. Iain Brighton Says:

    @Martin,

    WOW! Gobsmacked. Dumbfounded. I will attempt to keep my response succinct as I can only assume that you have completely missed the point.

    Do any one of Carl’s numerous scripts produce a Word document/report? Absolutely. Do Carl’s scripts save Carl from manually creating a 100+ page reports for his customers when they ask? Definitely. Fortunately Carl makes his blood, sweet and tears available so others can benefit. Evidently you don’t need any configuration reports in Word format, but 130,000+ total downloads is “job done” in my book – so thank you Carl!

    Now; are Carl’s scripts “pure” PowerShell or “pretty?” Nope – nowhere near. Does Carl pretend otherwise? Never, ever! Can they be improved? Unquestionably.

    Rather than simply attacking Carl for the results of his mammoth efforts thus far, what you should actually be doing is offering your expertise to help out. As we say in the UK, “Put up or shut up!” Provide some constructive feedback. Offer to write or rewrite the odd function. Get involved!

    I hope that you receive this as constructive feedback and I look forward to seeing your contributions in future versions .

    Iain

    Reply

  3. Jeff Wouters [MVP Windows PowerShell] Says:

    Hello Martin,

    Normally I don’t reply to comments on the websites of other people, but for a guy as amazing as you I’ll gladly make an exception.

    All you write about, except when you talk about the amount of code, is rather abstract. Please be concrete! This so that we can all learn from your great intellect.
    Keep in mind that Carl isn’t a PowerShellian (his words). He learned it on the fly while writing these scripts, with a lot of effort and determination.
    As an MVP I help Carl with his learning curve, provide basic code when asked for, etc. If I were to re-write all of his scripts in a way where I would think it’s done the best way possible, a developer could see it and start crying because his/her way of coding is just very different from mine.

    Why do I think you’re such an amazing person? Well, only a great and amazing guy could provide a 310 word comment without actually saying something. Just know that you’re bashing 2500+ hrs of work, and that’s only counting the hours Carl has put into those scripts.

    You write that Carl is murdering PowerShell.
    Why? Please, give examples! Again, please be concrete!

    I think that, looking at your comments, you must be a truly gifted scripter/coder. The code is free so… please take the code, re-write where needed and share it with the world. Looking the fact that PowerShell is very flexible and the community has a hard time establishing generally accepted best practices, I’ll bet we can find a ‘few’ things to point out in your code that have some room for improvement…

    I don’t know about Carl, but I will gladly enter a discussion with you. Maybe you didn’t knew that you’re not required to endorse what you’ve just witnessed? Nobody is forcing you to… #JustSaying

    You may have valid points about Carl’s code. But without being concrete about them, so none of that abstract blahblah bashing stuff, you’ll come over as that kid in kindergarten that thinks he’s better than anyone else, but really isn’t. I can’t imagine this would be your goal…

    Hey, I’ve just done some research on your name. On the PowerShell.org forum you’re kindly helping people. Great job!
    http://powershell.org/wp/forums/users/martin-nielsen/replies/
    I also see that you’re oldest reply there is just two weeks old… you’re new to the community? Welcome! I also found your blog: http://hardcode.dk/category/powershell
    Hopefully we’ll see some more PowerShell related blog posts (currently just 1 :-( ) so that we may learn from your brilliance?

    Jeff.

    Reply

  4. Martin Nielsen Says:

    I really hate to be this guy, I really do, but can I assume this script has been paid for by someone?

    I have never in my life seen such a mishmash of unintelligible “code” and copy/paste.

    I can not believe you have had Microsoft MVPs to help you do this. I really can not.

    First of all what is the use case for this? Run once, save the Word document somewhere and that’s it? — Sorry, export the configuration from one server, import it on another and THEN run this script, no this tool, once?

    Why in the world would you do this? I cannot fathom who could possibly benefit from reading a DHCP server configuration in a Word document? Please do explain the point.

    Next I cannot fathom why it needs to support exporting to 12 different versions of Word. Again, why is it even exporting to Word? Who, in 12 different countries, could possibly gain anything by reading a DHCP server configuration file?

    I don’t have the words to express my discontempt as I scroll down through this script. Do you realize this is a 6500 line script that exports a DHCP server configuration?

    There is practically no documentation of the code written. There’s no reasoning or explanation as to why all of the code is one big bag of copy/paste, and the hacks… the hacks! There are so many unbelievable hacks. You’re murdering PowerShell!

    I’ve hit line 2500 I can’t read anymore. I’m sorry, I really am, but this script really does not deserve to be put on the internet, and whoever paid you to do it deserves their money back. That is my professional opinion.

    I will happily discuss any part of my criticism with you, I even provided my email just in case, but I cannot in any way endorse what I have just witnessed.

    Reply

Leave a Reply

Current day month ye@r *