question

Chapter7-2723 avatar image
0 Votes"
Chapter7-2723 asked KyleXu-MSFT rolled back

Guest users in office 365

Hi,

I have number of guest users in office 365. Each guest user is member of different multiple groups.

I want to see the list of all guest users and their groups. After that the complete information should be export in excel file. thanks



Regards

azure-active-directoryoffice-exchange-online-itpro
· 1
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

@Chapter7-2723
I am writing here to confirm with you any update about this thread now?
If the suggestion below helps, please be free to accept it as an answer for helping more people.

0 Votes 0 ·
MarileeTurscak-MSFT avatar image
0 Votes"
MarileeTurscak-MSFT answered MarileeTurscak-MSFT edited

Hi @Chapter7-2723,

The best option for you is to use something like this script that queries all of the guest users and their group membership:

To query the guest users, you can use:

 Get-AzureADUser -All $true -Filter "UserType -eq 'Guest'"

OR

 Get-AzureADUser -Filter "UserType eq 'Guest'" | select DisplayName, Mail


To export the users to a CSV file you can use:

 Get-AzureADUser -Filter "UserType eq 'Guest'" | select DisplayName, Mail | Export-Csv guests.csv -NoTypeInformation    

Then you can use Get-AzureADUserMembership for individual users and run a ForEach loop to get it for everyone.

The most straightforward thing to do would be to follow the blog post, Export Office 365 Guest User Report with their Membership, and use the accompanying GetUserReport.ps1 script.

Hope this helps!

https://o365reports.com/2020/11/12/export-office-365-guest-user-report-with-their-membership/

5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

KyleXu-MSFT avatar image
0 Votes"
KyleXu-MSFT answered

@Chapter7-2723

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:
140410-qa-kyle-14-14-26.png
140444-qa-kyle-14-15-47.png


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.



5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.