Microsoft Active Directory Documentation Script Update Version 1.20

April 22, 2016

Active Directory, PowerShell

WOW! Whatever the PowerShell team did to the latest version of PowerShell Version 5 kicked my butt!!!!! Many things that used to work in my scripts, no longer worked. It took me seven hours to fix all the issues the latest V5 found in this script.

Version 1.20 22-Apr-2016

  • Fixed numerous issues discovered with the latest update to PowerShell V5
  • Color variables needed to be [long] and not [int] except for $wdColorBlack which is 0
  • Changed from using arrays to populating data in tables to strings
  • Fixed several incorrect variable names that kept PDFs from saving in Windows 10 and Office 2013
  • Fixed the rest of the $Var -eq $Null to $Null -eq $Var
  • Removed a couple of invalid $Table references
  • Removed blocks of old commented out code
  • Removed the 10 second pauses waiting for Word to save and close.

One of the testers for another script was having issues getting a PDF file created in Windows 10 with Office 2013. There were no issues with prior versions of Windows or PowerShell. I built a test VM with Windows 10 and Office 2013 both 64-bit. Sure enough, I had the same problem – no PDF. I was able to create a Word document but when I looked at the report a lot of the data was missing and most of the colors used for the Word tables were gone. Whiskey Tango Foxtrot?????

I added an $error.clear() at the top of the script and then $error as the last line. Holy Crap Batman!!! Over 2000 lines were copied into Notepad++. There were just over 500 errors!!!

There were several typos in variable names (like $D0main instead of $Domain) that even though I had Strictmode enabled had never been flagged. One of the bad variables was one that kept the PDF file from being saved.

The most confusing to this non-programmer/developer was “invalid type casting”. It took me a good while to figure out that meant all but one of my color variables needed to be cast/defined as [long] and not [int]. Why that makes a difference I have no idea. Only the $wdColorBlack variable, which is 0, had to stay [int] or it got the “invalid casting” error.

I spent several hours cleaning up the rest of all the remaining fixable errors listed by $error.  Now to go through all the other scripts and fix the same issues so you can use the scripts with the latest version of PowerShell 5.

What really puzzles me is that all these issues have been in the various scripts since Word support was added in January 2013. How the scripts actually worked beats the heck out of me.

I want to give a HUGE shout out to an extremely thorough and persistent tester David M. for sticking through and helping me find a bunch of other issues in the scripts and causing me seven hours of work.

There are so many changes to the script I bumped the version number to 1.20.

You can always find the most current script by going to http://carlwebster.com/where-to-get-copies-of-the-documentation-scripts/

Thanks

Webster

About Carl Webster

Webster is a Sr. Solutions Architect for Choice Solutions, LLC 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

3 Responses to “Microsoft Active Directory Documentation Script Update Version 1.20”

  1. Myron Dupler Says:

    Hi

    I have a multi domain environment and I getting several errors when I try to run the ADDS script. I have a forest level domain with two child domains attached to it. When the script tries to write the domain data, ou data, group data, group policy data, and etc, I get the error below.

    VERBOSE: 08/15/2016 09:03:29: Writing domain data
    VERBOSE: 08/15/2016 09:03:29: Processing domain domain1.localdomain2.localdomain3.local
    WARNING: Error retrieving domain data for domain domain1.localdomain2.localdomain3.local.
    VERBOSE: 08/15/2016 09:03:30: Writing domain controller data
    VERBOSE: 08/15/2016 09:03:30: Writing OU data by Domain
    VERBOSE: 08/15/2016 09:03:30: Processing domain domain1.localdomain2.localdomain3.local
    WARNING: Error retrieving OU data for domain domain1.localdomain2.localdomain3.local
    VERBOSE: 08/15/2016 09:03:31: Writing group data
    VERBOSE: 08/15/2016 09:03:31: Processing groups in domain domain1.localdomain2.localdomain3.local
    WARNING: Error retrieving Group data for domain domain1.localdomain2.localdomain3.local
    VERBOSE: 08/15/2016 09:03:31: Writing domain group policy data
    VERBOSE: 08/15/2016 09:03:31: Processing group policies for domain domain1.localdomain2.localdomain3.local
    WARNING: Error retrieving domain data for domain domain1.localdomain2.localdomain3.local
    VERBOSE: 08/15/2016 09:03:31: Writing Group Policy data by Domain by OU
    VERBOSE: 08/15/2016 09:03:31: Processing domain domain1.localdomain2.localdomain3.local
    WARNING: Error retrieving OU data for domain domain1.localdomain2.localdomain3.local
    VERBOSE: 08/15/2016 09:03:32: Writing miscellaneous data by domain
    VERBOSE: 08/15/2016 09:03:32: Processing misc data for domain domain1.localdomain2.localdomain3.local
    WARNING: Error retrieving domain data for domain domain1.localdomain2.localdomain3.local

    Domain1.local is my forest level domain and domain2.local and domain3.local are my child domains.

    Any idea on how I can resolve these errors?

    Reply

Leave a Reply