我可以使用下面的腳本來獲取本地組的成員:如何通過PowerShell腳本獲取本地用戶的組?
$CompStat = Get-WmiObject win32_computersystem;
$Localhst = $CompStat.Name;
$Computer = [ADSI]('WinNT://'+$localhst+',computer');
$group = [ADSI]('WinNT://'+$Localhst+'/groupname,group');
$Members = @($group.psbase.Invoke("Members"));
$Members | ForEach-Object {$MemberNames += $_.GetType().InvokeMember("Name", 'GetProperty', $null, $_, $null);
Write-Output $MemberNames;
}
同樣如何獲得特定用戶的羣體?
你只對本地組織感興趣嗎? – websch01ar
是的。我只對本地團體感興趣。 –