December 15th, 2014

PowerTip: Require Specific Module in PowerShell Script

Doctor Scripto
Scripter

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

Author

The "Scripting Guys" is a historical title passed from scripter to scripter. The current revision has morphed into our good friend Doctor Scripto who has been with us since the very beginning.

0 comments

Discussion are closed.

Feedback