We have an Office 365 / On Premise Exchange hybrid environment. We have an active directory group and I am looking for a way to know the members of the group have On Premise Mailbox or Office 365 Mailbox. Usually we run below AD Power Shell script to get the group members and then run the second Exchange Power Shell to know the recipient type. Is there any way to combine both and run a single script from Exchange Shell ?
Get-ADGroupMember -Identity “Group Name” | Get-ADObject -Properties Name, DisplayName | Select-Object Name, DisplayName | Export-Csv C:\Temp\List.csv -NoType
Get-Content “C:\Temp\List.csv” | Get-User | Select-Object Name, DisplayName, UserPrincipalName, WindowsEmailAddress, RecipientType | Export-Csv C:\Temp\UserExInfo.csv -NoTypeInformation