Private/GetElevation.ps1
function GetElevation { if ($PSVersionTable.PSEdition -eq "Desktop" -or $PSVersionTable.Platform -eq "Win32NT" -or $PSVersionTable.PSVersion.Major -le 5) { [System.Security.Principal.WindowsPrincipal]$currentPrincipal = New-Object System.Security.Principal.WindowsPrincipal( [System.Security.Principal.WindowsIdentity]::GetCurrent() ) [System.Security.Principal.WindowsBuiltInRole]$administratorsRole = [System.Security.Principal.WindowsBuiltInRole]::Administrator if($currentPrincipal.IsInRole($administratorsRole)) { return $true } else { return $false } } if ($PSVersionTable.Platform -eq "Unix") { if ($(whoami) -eq "root") { return $true } else { return $false } } } |