April 25th, 2016

PowerTip: Specify that a script requires admin privileges to run

Doctor Scripto
Scripter

Summary: Learn how to require admin privileges to run a Windows PowerShell script.

Hey, Scripting Guy! Question How can I make sure that my Windows PowerShell script has administrator privileges to run?

Hey, Scripting Guy! Answer Use the #Requires directive and specify RunAsAdministrator. Here is an example:

#Requires -RunAsAdministrator

The Doctor

Author

The "Scripting Guys" is a historical title passed from scripter to scripter. The current revision has morphed into our good friend Doctor Scripto who has been with us since the very beginning.

0 comments

Discussion are closed.