我试着运行一个脚本,它会给予一个邮件分发组的mal参与者和他们的mailaddresses.对于参与者来说,它工作得很好,而对于所有者来说,它不工作,因为我只能得到字符串的显示名称.有没有一种方法可以通过交换用户的名称来获得Mailaddress.
# Get all distribution groups
$groups = Get-DistributionGroup -ResultSize Unlimited
# Loop through each group
foreach ($group in $groups) {
# Get the group's name and email address
$groupName = $group.Name
$groupEmail = $group.PrimarySmtpAddress
# Get the list of owners
$owners = $group.ManagedBy
# Get the list of participants
$participants = Get-DistributionGroupMember $group | Select-Object -
ExpandProperty PrimarySmtpAddress
#do smth with it
}
术语$Managed by只给出了Owners的字符串形式的显示名称。我已经尝试通过遍历所有者列表来访问邮件地址:
foreach ($owner in $owners) {
$ownerAddress = Get-Mailbox -Filter "displayName -eq '$owner'"
}
它不返回任何内容,也不返回-Anr Flag或-Credentails。
1条答案
按热度按时间y53ybaqx1#
Hi MirrahOH,您可以通过这条线从经理那里获得信息