Microsoft Secure Tech Accelerator
Apr 03 2024, 07:00 AM - 11:00 AM (PDT)
Microsoft Tech Community

Guest Users governance - stale guest users

Brass Contributor

Hello All

I want to reach out to community and ask how admins are managing and creating governance around Guest users (external users).

In O 365 tenant users can invite non-tenant users to participate in Teams or in SharePoint sites. But after the project is complete, they forget to remove them from the Team or Site. Also we see a lot of Guest users in Azure AD tenant that have not logged in last 30 days (I am using Azure AD Sign in logs to see this info). For obvious security reasons, we don't want to leave these Guest users active in our tenants.  I know we can get list of external users and their sign in data using Graph API. But my question is more around best practices.

 

 Are there any best practices on how to handle stale guest users? I did not see any MS official documentation around this topic. Please share your governance policies that you have setup for guest users.

 TIA. 

15 Replies

The "best practice" will vary greatly from one organization to the other, as some are very "open" in regards to guest users, other must allow their partners and customers, while organizations in certain industries will never even enable such a feature. Microsoft's own tool to manage guest user lifecycle is called Access Reviews (https://docs.microsoft.com/en-us/azure/active-directory/active-directory-azure-ad-controls-manage-gu...), but unfortunately the license requirements are very prohibitive for any organization not already invested in AAD Premium P2.

 

PowerShell and the Graph API give you all the tools you need in order to manage Guest users, so you can build your custom solution around it, if the above is too costly.

@Vasil Michev thank you for your response. 

I agree with you that Azure AD Premium P2 is expensive hence I am building my scripts and tools for External user management. Just wanted to ask community how long are you leaving an external user in Azure AD. We cannot leave inactive external users forever in the tenant. 

Running the script/tool on a monthly basis seems like a sensible approach. But again, depends on the organization policies, some organizations will be perfectly fine doing the cleanup once per quarter.

Does anyone have a Power Shell script that would provide a list of stale guest accounts with the last log in date for users who don't have a mailbox?  External users who have been granted access to sites or documents in classic SharePoint sites and modern Team and Communication sites don't have mailboxes. 

the only way I've seen to check user activity is to go to the sign in logs.

Aside from that nothing

Hi, old thread, Ive just posted a similar question:

https://techcommunity.microsoft.com/t5/identity-authentication/add-remove-external-guest-user-from-s...

 

What I found interesting is that SP has the power to create a guest tenant but not the reverse. Seems odd that when deleting a User from an SP site the option isn't presented to remove the AD tenant. In addition any SP sites that are deleted should present the Guest User Tenants to be remove also..... if the Guest User Tenant is in use on another Site then a simple warning/pop up to say "not removed as in use on other Sites"

 

One issue Ive thought of is the 1:5 ratio of LicenseUser:GuestUser…… how did you overcome this? Or did you keep paying for additional Tenant Licenses?

 

Hi.
I want to remove inactive users for 14 days And export to csv.
I write:
Remove-StaleGuests.ps1 -InactiveTimeSpan 14 -ExportCSVPath guest.csv -RemoveInactiveGuests:$true
But then happens nothing.. all users are still exist.

For pending users it works:
Remove-StaleGuests.ps1 -InactiveTimeSpan 14 -ExportCSVPath guest.csv -RemoveExpiredGuests:$true

But for removing inactive doesn't. How does it work??
If you could please add an issue in github and then we can triage the issue.

I have the same issue. This must be a relevant problem for a lot of organisations, and the fact that it is hard to disable stale guest users, let alone identify them, is incredible. The access reviews Microsoft pushes are worthless. What is needed is a catch all script that disables all guest accounts not signed in during the last X days. 

You have replied to a post being 3 years old. If you've read the conversation you'd see that there's actually a script added for doing just that https://github.com/JBines/Remove-StaleGuests

The access reviews are great btw removing guest users not responding for ex.

A quick search got me here as well
https://github.com/12Knocksinna/Office365itpros/blob/master/FindOldGuestUsers.ps1
Thank you, the script looks like it could fix some issues. However, I would hope that Microsoft could come up with a more 'official' solution. If I were to use this script in a prod environment, which guarantees do I have it works, if this is a best-effort solution from JBines.
As for the access reviews, users not comfortable with English, guest users not having any clue about their own group memberships, etc etc makes them not suitable for our needs. When Microsoft security engineers push clean-up of inactive users as a high priority, I would assume their flagship product Azure could support user friendly ways of ensuring this.

Use Tony Redmonds then? If you don't think your guest users can handle the review email, use a group owner then? (called sponsor in the docs).

You can always contact the official support https://docs.microsoft.com/en-us/microsoft-365/business-video/get-help-support?view=o365-worldwide
If you want something more official you could consider this from a MS dev but still script based. https://devblogs.microsoft.com/premier-developer/azure-active-directory-automating-guest-user-manage...

On my side we have been running this in prod for a couple of years now but there are a couple changes coming (Using service principles, Converting to graph api with the new lastlogon value, and sending a email reminder before guest accounts are deleted) I'm hoping to work complete this by the end of the year if other projects don't interfere.