如何找出:域管理员与否?

Ale*_*lex 4 powershell

我有一个帐户,例如(MyDomain\User1),它只能访问安装了Windows Server 2008 R2的VM,而不是其他任何东西.

我根本无法访问Active Directory(AD)和Dmain Controller(DC).

如何判断此特定帐户(MyDomain\User1)是否为域管理员?是否有任何Windows PowerShell命令?

谢谢 !

Knu*_*ger 8

很简单,只需检查当前用户是否为域管理员组的成员.

$CurrentUser = [System.Security.Principal.WindowsIdentity]::GetCurrent()
$WindowsPrincipal = New-Object System.Security.Principal.WindowsPrincipal($CurrentUser)

if($WindowsPrincipal.IsInRole("Domain Admins"))
{
    Write-Host "Currently running as a Domain Admin"
}
else
{
   Write-Host "Keep dreaming, you're not a Domain Admin."
}
Run Code Online (Sandbox Code Playgroud)