PowerShellで管理者以外のスクリプト実行をはじく
from PowerShell
PowerShellで管理者以外のスクリプト実行をはじく
code:powershell
if (!(Security.Principal.WindowsPrincipalSecurity.Principal.WindowsIdentity::GetCurrent()).IsInRole(Security.Principal.WindowsBuiltInRole::Administrator)) {
throw "This PowerShell script needs to be executed by an account with priviledges."
}