Blocking Administrator Scripts

by May 29, 2014

If you know that your script requires Administrator privileges, then you should add this to the top of your script:

#requires -runasadministrator

This line makes sure the script will run only if the caller owns local Administrator privileges. The line will not try and elevate the script. It will, however, make sure that the script won’t even start and break in the middle of something.

Twitter This Tip! ReTweet this Tip!