Created
October 4, 2015 18:34
-
-
Save rysstad/1c5989747099243c28ef to your computer and use it in GitHub Desktop.
Check whether or not Powershell is running as admin (elevated) or not
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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