Check if a Windows terminal is running as administrator

Test admin elevation in PowerShell with the WindowsPrincipal role check.

WindowsprivilegesadminpowershellLow risk
Run `([Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator)` — True means elevated, False means not.

01Command

Command
$ ([Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator)

02What it does

Many commands fail with misleading errors when the terminal lacks admin rights, so it is worth checking first. This one-liner compares the current token against the built-in Administrator role and prints True or False. In cmd, `net session` works as a quick probe: if it errors with access denied, the console is not elevated.

03Risk

RiskLow risk

04Undo

✓No undo needed — this command does not change persistent state.

05Sources

  • Get-NetFirewallProfile
    Microsoft Learn · vendor-doc · 2026-09-17
    Evidence: Returns Domain, Private and Public firewall profiles with their Enabled state.
  • Whoami - Windows CMD
    SS64 · technical · 2026-09-17
    Evidence: whoami /groups output includes the Mandatory Label integrity level; S-1-16-12288 indicates a high-integrity (elevated) process.

Last verified: 2026-09-18 · Category: Security & Privacy

06Related solutions