PowerTip: Require Specific Module in PowerShell Script

The Scripting Guys

Dr Scripto

Summary: Learn how to require a specific module in a Windows PowerShell script.

Hey, Scripting Guy! Question How can I prevent a Windows PowerShell script from running if it requires the Active Directory module
           and the module is not available?

Hey, Scripting Guy! Answer At first line of the script, use the #Requires statement to require the Active Directory module:

#Requires –Modules ActiveDirectory

The Scripting Guys
Dr Scripto

Follow Dr Scripto   

No Comments.