web
You’re offline. This is a read only version of the page.
close
Skip to main content
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Automate / Office 365 group - rem...
Power Automate
Unanswered

Office 365 group - remove disabled users

(0) ShareShare
ReportReport
Posted on by 147

With the current set of connectors, I am able to build a flow that can list groups where I am the owner, list their members, and remove disabled user accounts from the group. If you would like to see such a flow, let me know. 

But, what I am missing is to list all Office 365 groups in the tenant and do the same as above using a service account with a "Groups administrator" role assigned in AzureAD. 

I have looked at LogicApp but the set of connectors for this purpose is quite similar. 

Can you give me a tip on how to list all Office 365 groups without being an owner of those?

 

Thx in advance

Mike

Categories:
I have the same question (0)
  • Ellis Karim Profile Picture
    11,653 Super User 2025 Season 2 on at
    Re: Office 365 group - remove disabled users

    I've been able to follow the blog post below and list all AAD Groups:

    2021-12-22_23-25-20.png

    I managed to create a demo flow, based on a previous template I had, that lists all groups in my organisation:

    2021-12-22_23-29-50.png

     

    2021-12-23_00-36-18.png

    The API can only return a maximum of 999 items. There may be a way to get more results, but my AAD has less than 999 groups. See: Handling Pagination with the MS Graph API in Logic Apps and Power Automate

    if you need to get more than 999 items - but this is not something I have yet had to implement.

    2021-12-22_23-30-43.png

    I'm using  Azure Key Vault to keep API keys and other secrets secure. For testing you will need to paste in the secret for the HTTP action.

     

    The TenantID

    https://portal.azure.com/#blade/Microsoft_AAD_IAM/ActiveDirectoryMenuBlade/Overview

    2021-12-22_23-49-29.png

    Client ID (Application ID):

    2021-12-22_23-44-24.png

    Hope this helps.


    Ellis
    ____________________________________
    If I have answered your question, please mark the post as Solved.
    If you like my response, please give it a Thumbs Up.

  • Michal Z.  Profile Picture
    147 on at
    Re: Office 365 group - remove disabled users

    Thank you @ekarim2020 for a very detailed response. 

    This looks like a way to go. 

    I can see that using Graph API I can list groups (https://graph.microsoft.com/v1.0/groups?$filter/groupTypes eq 'unified'), list their owners and members, and even remove members.

    This way all I need from PowerAutomate or Logic App is to check if the user/member is enabled or not using Get user profile (V2) from Office 365 Users connector. And even the last part can be replaced with Graph API. 

  • Ellis Karim Profile Picture
    11,653 Super User 2025 Season 2 on at
    Re: Office 365 group - remove disabled users

    I prefer to use the available connectors and actions where possible. If these can't do what I need or it's going to be a lot more work and complexity that can be avoided, I'll look at using Graph API calls.

     

    There is also the following Office 365 Groups action:

    2021-12-24_09-59-02.png

    This returns a maximum of 100 items.  Using a graph API call with HTTP action has so far provided what I need.

     

    Ellis

  • metrognome Profile Picture
    59 on at
    Re: Office 365 group - remove disabled users

    I am actually on the lookout for a flow that will run a check on the members' mailtips and highlight those that are disabled for me ot remove/delete. 

    IF you have anything like this, would be interested to read.

  • Ellis Karim Profile Picture
    11,653 Super User 2025 Season 2 on at
    Re: Office 365 group - remove disabled users

    Sorry, I didn't understand sentence about mailtips:


    @metrognome wrote:

    I am actually on the lookout for a flow that will run a check on the members' mailtips and highlight those that are disabled for me ot remove/delete. 

    IF you have anything like this, would be interested to read.


    Ellis

  • Ellis Karim Profile Picture
    11,653 Super User 2025 Season 2 on at
    Re: Office 365 group - remove disabled users

    Sorry, I didn't understand sentence about mailtips:


    @metrognome wrote:

    I am actually on the lookout for a flow that will run a check on the members' mailtips and highlight those that are disabled for me ot remove/delete. 

    IF you have anything like this, would be interested to read.


    Ellis

  • metrognome Profile Picture
    59 on at
    Re: Office 365 group - remove disabled users

    Mailtips is basically one option of the Outlook/O365 connector and basically mailtip returns either the out of office of a user or a warning that the mailbox is no longer operational (discontinued, deleted or full).

    It is a "quick and dirty" shortcut to check for an accounts's status and (especially in flows) bypass people when their out of office is active.

  • Ellis Karim Profile Picture
    11,653 Super User 2025 Season 2 on at
    Re: Office 365 group - remove disabled users

    See if the following post helps:

    Determine users out of office status based on mailtips - Automatic Replies on or not

    https://powerusers.microsoft.com/t5/Building-Flows/Determine-users-out-of-office-status-based-on-mailtips-Automatic/m-p/599256/highlight/true#M79112

     

    And the following extract from a flow:

    Snag_160684f.png

     

    Also, the Search for users can return the account enabled status for each account:

    Snag_1632f4e.png

    Ellis

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Automate

#1
Michael E. Gernaey Profile Picture

Michael E. Gernaey 462 Super User 2025 Season 2

#2
Tomac Profile Picture

Tomac 456 Moderator

#3
abm abm Profile Picture

abm abm 243 Most Valuable Professional

Last 30 days Overall leaderboard