0
$groups = gc H:\Groups.txt
        Foreach ($group in $groups) {
            Get-ADGroupMember -Identity $group | ft $group

            }

这是我一直在尝试的,但只列出用户而不是他们所属的组。

谢谢亚历克斯

4

1 回答 1

3

未经测试,但这是你所追求的那种东西:

$groups = gc H:\Groups.txt

$report = @()
Foreach ($group in $groups) {
  Get-ADGroupMember -Identity $group | % {
    $report += New-Object PSObject -Property @{
      Group = $group
      Name = $_.name
    }
  }
}
$report | ft -Autosize
于 2013-08-29T13:38:37.433 回答