private/Tests/Test-IsAdministrator.ps1

function Test-IsAdministrator {
    <#
    .SYNOPSIS
        Returns $true when the current PowerShell session is running with
        Administrator privileges.
 
    .NOTES
        Author: David Segura
        Company: Recast Software
        Use Assert-OSDeployAdministrator to throw a terminating error instead of
        branching on the return value.
    #>

    [OutputType([bool])]
    param ()

    $identity  = [System.Security.Principal.WindowsIdentity]::GetCurrent()
    $principal = [System.Security.Principal.WindowsPrincipal]::new($identity)
    return $principal.IsInRole([System.Security.Principal.WindowsBuiltInRole]::Administrator)
}