PowerShell Enforcing script prerequisites

Help us to keep this website almost Ad Free! It takes only 10 seconds of your time:
> Step 1: Go view our video on YouTube: EF Core Bulk Insert
> Step 2: And Like the video. BONUS: You can also share it!

Syntax

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

Remarks

#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.



Got any PowerShell Question?