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.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

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: