如何在Powershell中检查用户是本地管理员,是显式的还是从组继承的?

如何在Powershell中检查用户是本地管理员,是显式的还是从组继承的?,powershell,admin,local,Powershell,Admin,Local,对于任何用户,而不仅仅是当前用户,是否有一种简单的方法可以做到这一点?WindowsIdentity类有一个UPN(UserPrincipalName): 您可以对远程服务器执行此操作吗?@Starks remote您可以远程使用gwmi-Class Win32\u GroupUser-ComputerName$Computer或gcim-Class Win32\u GroupUser-ComputerName$Computer,虽然要得到你想要的东西有些费事,而且没有自动嵌套的组解析。是什么引

对于任何用户,而不仅仅是当前用户,是否有一种简单的方法可以做到这一点?

WindowsIdentity类有一个UPN(UserPrincipalName):


您可以对远程服务器执行此操作吗?@Starks remote您可以远程使用
gwmi-Class Win32\u GroupUser-ComputerName$Computer
gcim-Class Win32\u GroupUser-ComputerName$Computer
,虽然要得到你想要的东西有些费事,而且没有自动嵌套的组解析。是什么引起了这个问题?比尔·斯图尔特想知道你是不是为了完全解决另一个问题而提出了错误的问题。@Matt对我的问题是正确的。确保你没有真正的安全感。
$WindowsIdentity  = New-Object System.Security.Principal.WindowsIdentity "bob@ad.org.tld"
$WindowsPrincipal = New-Object System.Security.Principal.WindowsPrincipal $WindowsIdentity

$WindowsPrincipal.IsInRole([System.Security.Principal.WindowsBuiltInRole]::Administrator)