Microsoft DHCP Documentation Script Version 1.1 Released
August 7, 2014
I have been working with a very talented and hard-working group of friends to help speed up the runtime of the various documentation scripts. This update of the Microsoft DHCP script is the first step towards the goal of having the scripts run as fast as possible and also towards adding HTML output.
Here is the list of changes in version 4.2:
- Cleanup the script’s parameters section
- Code cleanup and standardization with the master template script
- Requires PowerShell V3 or later
- Removed support for Word 2007
- Word 2007 references in help text removed
- Cover page parameter now states only Word 2010 and 2013 are supported
- Most Word 2007 references in script removed:
- Function ValidateCoverPage
- Function SetupWord
- Function SaveandCloseDocumentandShutdownWord
- Function CheckWord2007SaveAsPDFInstalled removed
- If Word 2007 is detected, an error message is now given and the script is aborted
- Cleanup Word table code for the first row and background color
- Add Iain Brighton’s Word table functions
- Add parameter for HTML for future updates
- Fix when -ComputerName was entered as LocalHost, output filename said LocalHost and not actual server name
The only fix in this script is for the -ComputerName parameter. When I was creating this update, I noticed that if LocalHost was entered for -ComputerName, the output file said LocalHost_DHCP_Inventory.docx (or .txt). This is now fixed where LocalHost is resolved to the DHCP server name.
I have added a new output parameter for HTML (for future updates). This script has always had an option to output in Formatted Text. The parameters section was getting very ugly looking and over complicated. Turns out I was making that section much more difficult than it needed to be. After simplifying the code, the help text for the parameters, to me, looks much better.
SYNTAX F:\dhcp_inventory_V1_1.ps1 [-MSWord] [-ComputerName <String>] [-IncludeLeases] [-AddDateTime] [-CompanyName <String>] [-CoverPage <String>] [-UserName <String>] [<CommonParameters>] F:\dhcp_inventory_V1_1.ps1 [-PDF] [-ComputerName <String>] [-IncludeLeases] [-AddDateTime] [-CompanyName <String>] [-CoverPage <String>] [-UserName <String>] [<CommonParameters>] F:\dhcp_inventory_V1_1.ps1 [-Text] [-ComputerName <String>] [-IncludeLeases] [-AddDateTime] [<CommonParameters>] F:\dhcp_inventory_V1_1.ps1 [-HTML] [-ComputerName <String>] [-IncludeLeases] [-AddDateTime] [<CommonParameters>]
This script has always required PowerShell version 3 or later and Word 2007 is now no longer supported.
This script contains the code for Iain’s new table functions. Iain’s table functions populate Word tables about 95% faster than my old method. Over time, I will move all the Word tables in this script to use Iain’s new table functions. Eventually, HTML output will be added once someone comes up with a generic way to create HTML output that works in the master template script.
When I was creating the original DHCP and Active Directory scripts, I found out the code I was using for the header row in a Word table was too verbose. I learned how to reduce the lines of code needed to set the header row and give it a background color and make the text bold.
You can always find the most current script by going to https://carlwebster.com/where-to-get-copies-of-the-documentation-scripts/