PowerTip: Require Specific Module in PowerShell Script


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

Comments (1)

  1. Valeras says:

    Thanks, just wanted to add script should be saved this to work.

Skip to main content