Powershell Needful Things put that in your pipeline



Posted by Jean Louw

So, it has been a while since I have posted anything to the blog, but I have a new script which I have spent some time on, and I have been using it at a couple of customer sites with great success.

The script is based off of the Exchange Server Health script by Paul Cunningham and actually uses his code to generate the HTML report.

You can schedule this script as a daily report.

To setup email notifications you can customize the $smtpsettings variable in the script to your SMTP server requirements.

Once the SMTP is configured, you can use the following parameters when starting the script:

-domainName Use the domain name switch to limit the report to a single domain. If you omit the switch all domains in the forest are included in the scope.
-ReportFile This switch will export the results to a file in the same folder with a name based on the scope of the report.
-SendEmail This switch will use the settings specified in the $smtpsettings variable to attempt to send the report as an HTML email message.

The report itself contains a couple of bits of information.

First the server DNS Host name, with the AD site the server is currently a member of. The next column will display the OS version and whether the machine is a VM or physical.

Finally, we check the FSMO role of the server in its current domain.

The tests are pretty self-explanatory, first off we check the server in DNS to ensure that the name can be resolved. Next a ping test to ensure that we can contact the server.

We then display the uptime, DIT drive free space and the OS drive free space.

The AD specific tests check a couple of specific services, and then perform a DCDiag with some basic tests.

The last column indicates how long the script took to execute against the server. This is a great indication of performance problems, or network bandwidth or latency problems connecting to the server. Any processing time longer than the over all average is marked I amber.

The script can be downloaded from https://github.com/technologicza/Test-DomainControllerHealth.ps1

A special word of thanks to:

Paul Cunningham for the HTML generating code.
Gabriel Gumbs and Dhillan Kalyan for testing.

If you want to contribute to the development and or testing, please let me know via Twitter @jeanlouw.