PowerTip: Require Specific Module in PowerShell Script

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

0 comments

Comments are closed. Login to edit/delete your existing comments