List all guest users (including Initiated By

%3CLINGO-SUB%20id%3D%22lingo-sub-1402028%22%20slang%3D%22en-US%22%3EList%20all%20guest%20users%20(including%20Initiated%20By%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1402028%22%20slang%3D%22en-US%22%3E%3CP%3EHi%20everyone!%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI'm%20looking%20for%20a%20simple%20way%20to%20list%20all%20guest%20users%20in%20my%20tenant.%20I%20would%20also%20like%20to%20include%20two%20more%20properties.%20Here%20is%20where%20I'm%20stuck%20and%20could%20need%20some%20help%20%3A)%3C%2Fimg%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CUL%3E%3CLI%3EThe%20Account%2FUPN%20who%20invited%20the%20guest%3C%2FLI%3E%3CLI%3EThe%20Department%20of%20the%20above%20Account%2FUPN%20%5E%3C%2FLI%3E%3C%2FUL%3E%3CP%3EThis%20is%20what%20I%20came%20up%20with%20for%20listing%20the%20guest%20users.%20What%20would%20be%20an%20easy%20way%20to%20include%20to%20above%20properties%3F%3CBR%20%2F%3E%3CBR%20%2F%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CPRE%20class%3D%22lia-code-sample%20language-powershell%22%3E%3CCODE%3EGet-AzureADUser%20%7Cwhere%20%7B%24_.UserType%20-eq%20'Guest'%7D%20%7CSelect%20DisplayName%2C%20AccountEnabled%2C%20mail%2C%20CreationType%2C%20UserState%20%7CFT%20%3C%2FCODE%3E%3C%2FPRE%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%3CBR%20%2F%3EIn%20the%20Azure%20AAD%20portal%20under%20Audit%20Logs%20we%20are%20able%20to%20view%20a%20part%20of%20this%20info%20(the%20field%20is%20called%20%3CSTRONG%3EInitiated%20By%3C%2FSTRONG%3E)...however%20there%20is%20no%20way%20to%20add%20the%20Department-property%20in%20that%20UI%20report.%20Powershell%26nbsp%3B%20to%20the%20rescue%20then%3F%20%3A)%3C%2Fimg%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3C%2FP%3E%3CP%3EThanks!%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-1402028%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EAdmin%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EIdentity%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EOffice%20365%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E
New Contributor

Hi everyone!

 

I'm looking for a simple way to list all guest users in my tenant. I would also like to include two more properties. Here is where I'm stuck and could need some help :)

 

  • The Account/UPN who invited the guest
  • The Department of the above Account/UPN ^

This is what I came up with for listing the guest users. What would be an easy way to include to above properties?

 

Get-AzureADUser |where {$_.UserType -eq 'Guest'} |Select DisplayName, AccountEnabled, mail, CreationType, UserState |FT 

 


In the Azure AAD portal under Audit Logs we are able to view a part of this info (the field is called Initiated By)...however there is no way to add the Department-property in that UI report. Powershell  to the rescue then? :)

Thanks!

1 Reply

That information (the initiated by data) is only accessible via the audit logs, which means you have to crawl the logs for every such events. And it also means its available only for a preset duration, meaning all the "old" guest users will not have any entries available. If you want to go that route, I'd suggest using the Graph API endpoints: https://docs.microsoft.com/en-us/graph/api/resources/azure-ad-auditlog-overview?view=graph-rest-1.0