icinga-powershell-framework/core/include/utils/AdminShell.ps1
2018-11-06 17:14:49 +01:00

12 lines
No EOL
481 B
PowerShell

$AdminShell = New-Object -TypeName PSObject;
$AdminShell | Add-Member -membertype ScriptMethod -name 'IsAdminShell' -value {
$CurrentIdentity = [System.Security.Principal.WindowsIdentity]::GetCurrent();
$WindowsPrincipal = New-Object System.Security.Principal.WindowsPrincipal($CurrentIdentity);
if (-Not $WindowsPrincipal.IsInRole([System.Security.Principal.WindowsBuiltInRole]::Administrator)) {
return $FALSE;
}
return $TRUE;
}
return $AdminShell;