Skip to content

Instantly share code, notes, and snippets.

@rysstad
Created October 4, 2015 18:34
Show Gist options
  • Save rysstad/1c5989747099243c28ef to your computer and use it in GitHub Desktop.
Save rysstad/1c5989747099243c28ef to your computer and use it in GitHub Desktop.
Check whether or not Powershell is running as admin (elevated) or not
If ( ([Security.Principal.WindowsPrincipal] [Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole] "Administrator")) {
Write-Output "Powershell running with elevated privileges"
} else {
Write-Output "Powershell running as user, without admin privileges"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment