Enforce running the script as admininstrator
suggest change#requires -RunAsAdministrator
After trying to run this script without admin privileges, you will see this error message
.\script.ps1 : The script ‘script.ps1’ cannot be run because it contains a “#requires” statement for running as Administrator. The current Windows PowerShell session is not running as Administrator. Start Windows PowerShell by using the Run as Administrator option, and then try running the script again.
Found a mistake? Have a question or improvement idea?
Let me know.
Table Of Contents