Install Azure AD PowerShell and connect to Azure AD first. Run it with administrator right.
Then you could use the script below to get the result that you wanted(Save this script to a .PS1 file, then run this .PS1 file after connect to Azure AD):
$data =@()
$Users = Get-AzureADUser | where{$_.UserType -eq "Guest"} | select ObjectId,DisplayName
foreach ($user in $users){
$data+= Get-AzureADUserMembership -ObjectId $user.ObjectId | select @{Expression={$user.DisplayName};Label="User";},@{Expression={$_.DisplayName};Label="GroupName";}
}
$data | Export-Csv C:\Users\demoUser\Desktop\infor.csv -NoTypeInformation
The result:
If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.