I have user power automate to return the sharepoint Site owners using API call as "_api/web/associatedownergroup/users". I got the desired result of SharePoint site owners but in that list it also includes Owners who have left the organization. How can I remove those names from the list so that i will get result of only active owners of that sharePoint site?
-
Can you elaborate more on "left the organization"? does it mean those users are Inactive users (blocked sign-in) or those users are deleted?– Kalpesh VaghelaCommented Jun 20, 2023 at 8:08
-
Users deleted!!– Prathamesh BhaleraoCommented Jun 20, 2023 at 9:00
-
So do you want it as one time process like from all the sites, deleted users from tenant should be removed from Owner groups all well? or you want to check every time in your Power Automate whenever you get users using API?– Kalpesh VaghelaCommented Jun 20, 2023 at 10:45
1 Answer
Very often you don't delete users from Active Directory, you just disable them.
Get user profile (V2)
action will return you this information under "Account enabled?" property. In expression it looks like this for example ( outputs('Get_user_profile_(V2)')?['body/accountEnabled']
).
You will need to loop with Apply to each
action through the list of the owners and use that Get user profile (V2)
action inside:
- to check the status of the account enabled/disabled.
- In case the action will throw you an error that user has not been found, it will tell you that the user does not exists anymore
Based on this you will know which user is active or not.