简体   繁体   English

如何获取邮件联系人所属的所有组?

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

This code will find all groups to which a particular email account or mail-user account belongs. 此代码将查找特定电子邮件帐户或mail-user帐户所属的所有组。

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; 但是,在O365中,您可以拥有不是用户的mail-contacts -它们仅用于邮件列表; they don't have a windowsliveid , so they won't be found in $_.Members . 它们没有windowsliveid ,因此不会在$_.Members windowsliveid中找到它们。

How can I find all groups that a particular mail-contact belongs to? 如何找到特定mail-contact所属的所有组?

Well, likeafoxx over in reddit came up with a solution. 好吧, redafit中的likeafoxx提出了一个解决方案。

$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 . 显然,如果赶上get-contact值到一个变量,然后get-group$_.members 可以搜索。 I was putting the string value for the name there, but that always turned up empty. 我在此处输入名称的字符串值,但始终变成空。 This works like a charm. 这就像一个魅力。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM