One of the most common things I use Powershell for requires the ActiveDirectory module. In its self, this isn’t an issue, I know I have it installed and that it will import automatically. The problem comes when sending or transferring the script to someone else.
If the device running the script doesn’t have some modules installed or available a script will fall-over.
This script simply puts some belts and braces around importing the ActiveDirectory module inline with the Powershell Framework
The script will check for an RSAT installation
The logs produced should look like this
*************************************************************
Started logging at [11/10/2017 15:46:01].
*************************************************************
*************************************************************
[11/10/2017 15:46:01] Loading Module: Connect-AD
[11/10/2017 15:46:01] Importing AD Modules
[11/10/2017 15:46:01] Checking for ActiveDirectory Module
[11/10/2017 15:46:01] ActiveDirectory module is already loaded
...