如果我使用的是PowerShell Cmdlet:
Get-ADGroup -Server“my-dc”-Filter {name -like“* Blue * 1”} | Get-ADGroupMember | Out-File $ output
有没有办法可以在文本文件中输出找到的组名?目前,这只会将组成员输出到文件中。
答案 0 :(得分:1)
另一种变体:
Get-ADGroup -Filter {Name -like "*demo*"} | % { "GroupName: $($_.Name)"; Get-ADGroupMember $_ } | Out-File C:\Scripts\Group.txt
这将在文本文件中有类似的内容:
GroupName:DemoUsers
distinguishedName:CN = Ravikanth,CN = Users,DC = BarCamp,DC = in 姓名:Ravikanth objectClass:user objectGUID:c4257f39-c84e-43e3-adb2-dfb6d13a8f2a SamAccountName:Ravikanth SID:S-1-5-21-4177501474-3918321425-3674396201-1000
答案 1 :(得分:0)
试试这个:
Get-ADGroup | %{
# Here $_ is the group, do with it what you will :)
$_
$_ | get-ADGroupmember
}
答案 2 :(得分:0)
Get-ADGroup -Server "my-dc" -Filter {name -like "*Blue*1"} | Get-ADGroupMember | foreach { $_.name | out-file -FilePath $output -Append}