PowerShell Enforcing script prerequisites


  • #Requires -Version <N>[.<n>]
  • #Requires –PSSnapin <PSSnapin-Name> [-Version <N>[.<n>]]
  • #Requires -Modules { <Module-Name> | <Hashtable> }
  • #Requires –ShellId <ShellId>
  • #Requires -RunAsAdministrator


#requires statement can be placed on any line in the script (it doesn't have to be the first line) but it must be the first statement on that line.

Multiple #requires statements may be used in one script.

For more reference, please refer to official documentation on Technet - about_about_Requires.