From 2183b1efa5a07b31eca80b5cef5dd375f61cb460 Mon Sep 17 00:00:00 2001 From: "Brian T. Jackett" Date: Mon, 10 Feb 2020 08:25:15 -0500 Subject: [PATCH] Fix script to pull proper EXO module Fix script to use proper EXO module for Unified Group commandlets. Also modify properties returned from members to be more readable. --- Office 365/PS_Get_O365_Group_Members.ps1 | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/Office 365/PS_Get_O365_Group_Members.ps1 b/Office 365/PS_Get_O365_Group_Members.ps1 index b19e6ba..cde6cab 100644 --- a/Office 365/PS_Get_O365_Group_Members.ps1 +++ b/Office 365/PS_Get_O365_Group_Members.ps1 @@ -1,4 +1,4 @@ -############################################################################################################################################ +############################################################################################################################################ # Script that allows to get the members for each Office 365 Group defined in an Office 365 tenant. # Required Parameters: N/A. ############################################################################################################################################ @@ -19,8 +19,7 @@ function Get-O365Members foreach ($O365Group in $O365Groups) { Write-Host "Members of Group: " $O365Group.DisplayName -ForegroundColor Green - Get-UnifiedGroupLinks –Identity $O365Group.Identity –LinkType Members - Write-Host + Get-UnifiedGroupLinks –Identity $O365Group.Identity –LinkType Members | Select-Object -Property DisplayName, PrimarySmtpAddress } } catch [System.Exception] @@ -34,8 +33,8 @@ $sUserName="" $sMessage="Introduce your Office 365 Credentials" #Connection to Office 365 $msolCred = Get-Credential -UserName $sUserName -Message $sMessage -Connect-MsolService -credential $msolCred +$Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri https://outlook.office365.com/powershell-liveid/ -Credential $msolCred -Authentication Basic -AllowRedirection +Import-PSSession $Session -AllowClobber #Getting Groups Information Get-O365Members -