PowerShell for Windows Admins

Feb 25 2014   4:51PM GMT

Requires

Richard Siddaway Richard Siddaway Profile: Richard Siddaway

You may have seen this at the top of scripts or modules

#Requires –Version 3

This will stop the script running if the PowerShell version is 2.0 or below.

Other options are available

#Requires –PSSnapin      can be used to force the loading of a snapin

#Requires –Modules     can be used to force importing of modules

#Requires –Shellid    controls which shells the script can run in.  Default PowerShell installs have the ISE and console

#Requires –RunAsAdminstrator  – script must be running in instance of PowerShell with elevated privileges

These provide a simple and easy way to control execution without lots of code. I particularly like the last one.

 Comment on this Post

 
There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when other members comment.

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to:

Share this item with your network: