我编写了一个小的 powershell 脚本来输出所有分发列表的所有成员(包括动态的)。
$output = ""
$DLList = get-distributiongroup
foreach ($DL in $DLList) {
$Dmember=get-distributiongroupmember $DL
$Dname=$DL.name
write-output "$Dname"
$output += "$Dname`r`n"
foreach ($Member in $Dmember) {
$MName=$Member.DisplayName
write-output "-$MName"
$output += "-$MName`r`n"
}
write-output ""
$output += "`r`n"
}
$DDLList = get-dynamicdistributiongroup
foreach ($DL in $DDLList) {
$Dmember=get-Recipient -Filter $DL.RecipientFilter
$Dname=$DL.name
write-output "$Dname"
$output += "$Dname`r`n"
foreach ($Member in $Dmember) {
$MName=$Member.DisplayName
write-output "-$MName"
$output += "-$MName`r`n"
}
write-output ""
$output += "`r`n"
}
$output | Tee-Object -file data.txt
除了我的 DL 中的一个包含邮件联系人之外,这很好用。有没有办法将它们包含在上面的脚本中?
谢谢。