Check if a Windows terminal is running as administrator
Test admin elevation in PowerShell with the WindowsPrincipal role check.
01Command
$ ([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
04Undo
✓No undo needed — this command does not change persistent state.
05Sources
- Get-NetFirewallProfileEvidence: Returns Domain, Private and Public firewall profiles with their Enabled state.
- Whoami - Windows CMDEvidence: 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
Search inside text files and logs with regex, returning file, line number and match.
Create or update a .zip from any files or folder contents straight from PowerShell.
A built-in PowerShell one-liner that answers 'is port 5432/3389/443 actually open through this network?' — no telnet client needed.