May 19 2020 04:05 AM
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 🙂
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!
May 19 2020 09:00 AM
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