I have a group of PowerShell scripts that sometimes get run together, sometimes one at a time. Each of the scripts requires that a certain snap-in be loaded.
Right n
Surpisingly, nobody mentioned the native way for scripts to specify dependencies: the #REQUIRES -PSSnapin Microsoft.PowerShell...
comment/preprocessor directive. Just the same you could require elevation with -RunAsAdministrator
, modules with -Modules Module1,Module2
, and a specific Runspace version.
Read more by typing Get-Help about_requires