Skip to content

Instantly share code, notes, and snippets.

@scriptingstudio
Created May 22, 2025 07:16
Show Gist options
  • Select an option

  • Save scriptingstudio/3e3ee514a24e463de2ef371cfaa9f763 to your computer and use it in GitHub Desktop.

Select an option

Save scriptingstudio/3e3ee514a24e463de2ef371cfaa9f763 to your computer and use it in GitHub Desktop.
Culture invariant admin privileges test in cmd
powershell.exe -executionpolicy bypass -noninteractive -nologo -noprofile -command "&{ If (-not ([Security.Principal.WindowsPrincipal] [Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole] 'Administrator')) {write-warning 'You must run this script as an Administrator!'; cmd.exe /c pause; exit 1000} }"
if ERRORLEVEL 1000 goto :EOF
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment