Microsoft Active Directory Documentation Script Version 1.1 Released
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 Active Directory (AD) script is the first step towards the goal of having the scripts run as fast as possible and also towards adding Formatted Text and 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 parameters for Text and HTML for future updates
- Cleanup retrieving services and service startup type with Iain Brighton’s optimization
- Move Services table to new table functions
- Add numeric values for ForestMode and DomainMode
- Removed most of the [gc]::collect() as they are not needed
- Removed the CheckLoadedModule function
- Added a Requires activedirectory module statement>
The only fix in this script is for the Forest and Domain Modes. When I was creating this update and testing on my Server 2012 R2 Forest, I noticed that the Forest and Domain modes were no longer text entries and were now numeric values. For example, instead of a Forest mode value of “Windows2012R2Forest”, a “6” was return by the Get-ADForest cmdlet. Same for Get-ADDomain. I added the appropriate numeric values to both Switch statements.
I have added new output parameters for Formatted Text and HTML (for future updates). 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:\ADDS_Inventory_V1_1.ps1 [-MSWord] [-Hardware] -ADForest <String> [-ComputerName <String>] [-Services] [-AddDateTime] [-CompanyName <String>] [-CoverPage <String>] [-UserName <String>] [<CommonParameters>] F:\ADDS_Inventory_V1_1.ps1 [-PDF] [-Hardware] -ADForest <String> [-ComputerName <String>] [-Services] [-AddDateTime] [-CompanyName <String>] [-CoverPage <String>] [-UserName <String>] [<CommonParameters>] F:\ADDS_Inventory_V1_1.ps1 [-Text] [-Hardware] -ADForest <String> [-ComputerName <String>] [-Services] [-AddDateTime] [<CommonParameters>] F:\ADDS_Inventory_V1_1.ps1 [-HTML] [-Hardware] -ADForest <String> [-ComputerName <String>] [-Services] [-AddDateTime] [<CommonParameters>]
This script now requires PowerShell version 3 or later and Word 2007 is 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. I have already moved the Hardware and Services tables to the new Word 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/