{"id":3731,"date":"2018-11-01T23:12:01","date_gmt":"2018-11-01T23:12:01","guid":{"rendered":"https:\/\/pariswells.com\/blog\/?p=3731"},"modified":"2018-11-01T23:12:01","modified_gmt":"2018-11-01T23:12:01","slug":"powershell-list-group-memberships-in-365-of-distribution-groups-and-unified-groups","status":"publish","type":"post","link":"https:\/\/pariswells.com\/blog\/code\/powershell-list-group-memberships-in-365-of-distribution-groups-and-unified-groups","title":{"rendered":"Powershell &#8211; List group Memberships in 365 of Distribution groups and Unified groups"},"content":{"rendered":"<p>&nbsp;<\/p><p>[pastacode lang=&#8221;markdown&#8221; manual=&#8221;%24groups%3DGet-UnifiedGroup%0A%0Aforeach(%24group%20in%20%24groups)%0A%7B%0A%20%20%20%20Write-Host%20%22************************************************%22%0A%20%20%20%20Write-Host%20%22GroupName%3A%20%22%20%20%24group.DisplayName%0A%20%20%20%20Write-Host%20%22Email%3A%20%22%20%20%24group.primarySMTPAddress%0A%20%20%20%20Write-Host%20%22&#8212;%20Members%20&#8212;%22%0A%20%20%20%20%24membersOfGroup%3DGet-UnifiedGroupLinks%20-Identity%20%24group.Identity%20-LinkType%20Members%0A%20%20%20%20foreach(%24member%20in%20%24membersOfGroup)%0A%20%20%20%20%7B%20%20%20%20%20%20%20%0A%20%20%20%20%20%20%20%20Get-Recipient%20-Identity%20%24member.Name%20%7C%20select%20PrimarySmtpAddress%20%7CFormat-Wide%20%0A%20%20%20%20%7D%0A%20%20%20%20%20%0A%7D%0A%0A%0A%24groups%3DGet-DistributionGroup%0A%0Aforeach(%24group%20in%20%24groups)%0A%7B%0A%20%20%20%20Write-Host%20%22************************************************%22%0A%20%20%20%20Write-Host%20%22GroupName%3A%20%22%20%20%24group.DisplayName%0A%20%20%20%20Write-Host%20%22Email%3A%20%22%20%20%24group.primarySMTPAddress%0A%20%20%20%20Write-Host%20%22&#8212;%20Members%20&#8212;%22%0A%20%20%20%20%24membersOfGroup%3DGet-DistributionGroupMember%20-Identity%20%24group.Identity%0A%20%20%20%20foreach(%24member%20in%20%24membersOfGroup)%0A%20%20%20%20%7B%20%20%20%20%20%20%20%0A%20%20%20%20%20%20%20%20Get-Recipient%20-Identity%20%24member.Name%20%7C%20select%20PrimarySmtpAddress%20%7CFormat-Wide%20%0A%20%20%20%20%7D%0A%20%20%20%20%20%0A%7D&#8221; message=&#8221;&#8221; highlight=&#8221;&#8221; provider=&#8221;manual&#8221;\/]<\/p>","protected":false},"excerpt":{"rendered":"<p>&nbsp;[pastacode lang=&#8221;markdown&#8221; manual=&#8221;%24groups%3DGet-UnifiedGroup%0A%0Aforeach(%24group%20in%20%24groups)%0A%7B%0A%20%20%20%20Write-Host%20%22************************************************%22%0A%20%20%20%20Write-Host%20%22GroupName%3A%20%22%20%20%24group.DisplayName%0A%20%20%20%20Write-Host%20%22Email%3A%20%22%20%20%24group.primarySMTPAddress%0A%20%20%20%20Write-Host%20%22&#8212;%20Members%20&#8212;%22%0A%20%20%20%20%24membersOfGroup%3DGet-UnifiedGroupLinks%20-Identity%20%24group.Identity%20-LinkType%20Members%0A%20%20%20%20foreach(%24member%20in%20%24membersOfGroup)%0A%20%20%20%20%7B%20%20%20%20%20%20%20%0A%20%20%20%20%20%20%20%20Get-Recipient%20-Identity%20%24member.Name%20%7C%20select%20PrimarySmtpAddress%20%7CFormat-Wide%20%0A%20%20%20%20%7D%0A%20%20%20%20%20%0A%7D%0A%0A%0A%24groups%3DGet-DistributionGroup%0A%0Aforeach(%24group%20in%20%24groups)%0A%7B%0A%20%20%20%20Write-Host%20%22************************************************%22%0A%20%20%20%20Write-Host%20%22GroupName%3A%20%22%20%20%24group.DisplayName%0A%20%20%20%20Write-Host%20%22Email%3A%20%22%20%20%24group.primarySMTPAddress%0A%20%20%20%20Write-Host%20%22&#8212;%20Members%20&#8212;%22%0A%20%20%20%20%24membersOfGroup%3DGet-DistributionGroupMember%20-Identity%20%24group.Identity%0A%20%20%20%20foreach(%24member%20in%20%24membersOfGroup)%0A%20%20%20%20%7B%20%20%20%20%20%20%20%0A%20%20%20%20%20%20%20%20Get-Recipient%20-Identity%20%24member.Name%20%7C%20select%20PrimarySmtpAddress%20%7CFormat-Wide%20%0A%20%20%20%20%7D%0A%20%20%20%20%20%0A%7D&#8221; message=&#8221;&#8221; highlight=&#8221;&#8221; provider=&#8221;manual&#8221;\/]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[320],"tags":[],"class_list":["post-3731","post","type-post","status-publish","format-standard","hentry","category-code"],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/pariswells.com\/blog\/wp-json\/wp\/v2\/posts\/3731","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/pariswells.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/pariswells.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/pariswells.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/pariswells.com\/blog\/wp-json\/wp\/v2\/comments?post=3731"}],"version-history":[{"count":1,"href":"https:\/\/pariswells.com\/blog\/wp-json\/wp\/v2\/posts\/3731\/revisions"}],"predecessor-version":[{"id":3732,"href":"https:\/\/pariswells.com\/blog\/wp-json\/wp\/v2\/posts\/3731\/revisions\/3732"}],"wp:attachment":[{"href":"https:\/\/pariswells.com\/blog\/wp-json\/wp\/v2\/media?parent=3731"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/pariswells.com\/blog\/wp-json\/wp\/v2\/categories?post=3731"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/pariswells.com\/blog\/wp-json\/wp\/v2\/tags?post=3731"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}