PowerTip: Specify that a script requires admin privileges to run

Doctor 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


Discussion is closed.

Feedback usabilla icon