icinga-powershell-framework/core/include/utils/AdminShell.ps1

12 lines
481 B
PowerShell
Raw Normal View History

2018-11-06 11:14:49 -05:00
$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;