Summary: Learn how to require a specific module in a Windows PowerShell script.
How can I prevent a Windows PowerShell script from running if it requires the Active Directory module
and the module is not available?
At first line of the script, use the #Requires statement to require the Active Directory module:
#Requires –Modules ActiveDirectory