我尝试了以下脚本,并获取了该组的成员。
$CompStat = Get-WmiObject win32_computersystem;
$Localhst = $CompStat.Name;
$Computer = [ADSI]('WinNT://'+$localhst+',computer');
$group = [ADSI]('WinNT://'+$Localhst+'/Remote Desktop Users,group');
$Members = @($group.psbase.Invoke("Members"));
$Members | ForEach-Object {$MemberNames += $_.GetType().InvokeMember("Name", 'GetProperty', $null, $_, $null);}
但成员没有显示出来。如何打印成员?
答案 0 :(得分:1)
只需在脚本末尾添加Write-Host $MemberNames