Deleting user from Teams chat once M365 account has been deleted.

Jonathan Enrique Nieves Pagan 0 Reputation points
2024-09-30T15:50:32.5766667+00:00

Is there a way to make a policy to delete the the user form any MTeams chat once the user M365 account has been deleted from the admin portal?. I have a problem that the users keep appearing on the chats that they had access or when they are deleted form the Active Directory they become unknown to the chat. Is there a way to make a policy to delete the users flat on once the have been deleted?

Microsoft 365
Microsoft 365
Formerly Office 365, is a line of subscription services offered by Microsoft which adds to and includes the Microsoft Office product line.
4,929 questions
Microsoft Teams
Microsoft Teams
A Microsoft customizable chat-based workspace.
10,131 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. JimmyYang-MSFT 53,046 Reputation points Microsoft Vendor
    2024-10-01T08:57:18.9533333+00:00

    Hi @Jonathan Enrique Nieves Pagan

    Managing the removal of users from Microsoft Teams chats once their Microsoft 365 accounts have been deleted can be a bit complex, as there isn't an out-of-the-box policy specifically for this purpose. However, you can automate parts of the process to ensure that users are removed from Teams when their accounts are deleted in Active Directory (AD). Here's a general approach you can consider:

    1. Automate Account Deactivation and Deletion:
    • Use PowerShell scripts to automate the deactivation and deletion of accounts. You can schedule these scripts to run periodically and check for accounts that need to be removed.
    1. Using Microsoft Graph API:
    • Utilize the Microsoft Graph API to manage Teams users and their memberships in chats and teams. This allows you to programmatically remove users from chats.
    • You can create a script that triggers upon account deletion to remove the user from all teams and chats.
    1. Dynamic Groups and Policies:
    • Use Azure AD dynamic groups to manage memberships more effectively. When a user is deleted from Active Directory, their removal from dynamic groups can trigger subsequent actions for Teams.
    • Implement conditional access policies to restrict access once users are marked for deletion.

    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.



Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.