src/_Test-CciElevated.ps1

function _Test-CciElevated {
    <#
        True when the current session can write machine-wide locations.
 
        Windows only in practice; on any other platform there is no AllUsers
        module path worth guarding, so report elevated and let the caller's
        install fail honestly if it cannot write.
    #>

    [CmdletBinding()]
    param()

    if ($PSVersionTable.PSVersion.Major -ge 6 -and -not $IsWindows) { return $true }

    try {
        $identity = [Security.Principal.WindowsIdentity]::GetCurrent()
        ([Security.Principal.WindowsPrincipal]$identity).IsInRole(
            [Security.Principal.WindowsBuiltInRole]::Administrator)
    }
    catch {
        Write-Verbose "[cciget] Could not determine elevation: $_"
        $false
    }
}