我的脚本从我的 txt 文件中列出的每个 DL 中提取成员,但是有一些将安全组作为成员,我也想列出这些组中的成员。
set-adserversetting -viewentireforest $true
$groups = Get-Content -path 'C:\Users\test.txt'
$result =
foreach ($group in $groups) {
$members = Get-DistributionGroupMember -$group -ResultSize Unlimited
foreach ($user in $members) {
[PSCustomObject]@{
GroupName = $group
samAccountName = $user.samAccountName
distinguishedName = $user.distinguishedName
name = $user.name
}
}
}
$result | export-csv 'C:\Users\testing.csv' -notypeinformation