在Office365中获取联系人的memberof属性

Get memberof attribute of contact in Office365

有没有办法在 Office365 中获取 contact/user 的通讯组?我看不到 memberof 属性。

Get-MailContact -Identity Username | Format-List

你可以通过Get-ADObject获得它:

$Contact = Get-MailContact -Identity Username
(Get-ADObject -Identity $Contact.DistinguishedName -Properties 'MemberOf').MemberOf

或者(可能需要更多时间)没有 AD 模块:

$Contact = Get-MailContact -Identity Username
Get-DistributionGroup | ? {Get-DistributionGroupMember -Identity $_ | ? {$_.PrimarySmtpAddress -eq $Contact.PrimarySmtpAddress}}