PowerTip: Specify that a script requires admin privileges to run

The Scripting Guys

Dr Scripto

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

The Scripting Guys
Dr Scripto

Follow Dr Scripto   

No Comments.