Common/Public/Test-IsAdministrator.ps1

1
2
3
4
5
6
7
8
9
10
function Test-IsAdministrator
{
    
    [CmdletBinding()]
    param ()
    
    $currentUser = [Security.Principal.WindowsIdentity]::GetCurrent()
    (New-Object -TypeName Security.Principal.WindowsPrincipal -ArgumentList $currentUser).IsInRole([Security.Principal.WindowsBuiltinRole]::Administrator)
}