Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Function to test if the current session is running as an administrator
function Test-IsAdmin {
Tests if the user is an administrator
Returns true if a user is an administrator, false if the user is not an administrator
$identity = [Security.Principal.WindowsIdentity]::GetCurrent()
$principal = New-Object Security.Principal.WindowsPrincipal $identity
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment