How to get all groups that a mail-contact belongs to?

家住魔仙堡 提交于 2019-12-24 01:31:40

问题


This code will find all groups to which a particular email account or mail-user account belongs.

get-group | where-object -FilterScript {$_.Members -contains $user}

However, in O365 you can have mail-contacts who are not users - they are used just for mailing lists; they don't have a windowsliveid, so they won't be found in $_.Members.

How can I find all groups that a particular mail-contact belongs to?


回答1:


Well, likeafoxx over in reddit came up with a solution.

$contact = Get-Contact -Identity "<Contact's Name>"
Get-Group | Where-Object {$_.Members -contains $contact}

Apparently, if you catch the get-contact value into a variable, then get-group's $_.members can search for that. I was putting the string value for the name there, but that always turned up empty. This works like a charm.



来源:https://stackoverflow.com/questions/53310254/how-to-get-all-groups-that-a-mail-contact-belongs-to

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!