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

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Automate / Create Power Automate ...
Power Automate
Suggested Answer

Create Power Automate flow to bulk disable users in Business Central

(1) ShareShare
ReportReport
Posted on by 53
Hi,
 
I currently have a list of Microsoft 365 users. Due to company policy, when an employee leaves the company, their accounts are blocked and all its licenses removed. Accounts are not deleted. I exported the list of users from Microsoft 365 to an Excel file. One column indicates whether an account is blocked or not. 
 
There are a lot of users and I don't want to disable their account in Business Central one by one. (our BC is cloud based) Is it possible to create a Power Automate flow that opens this file and loops through the records in the Excel file? For every blocked acocunt, it would disable the account in Business Central.
 
Also I want to disable the account in Business Central right when an account is blocked. Could a Power Automate flow be created to detect when an account is blocked and then disable the BC account right away? Thanks!
 
Sincerely,
 
Jason
 
Categories:
I have the same question (0)
  • Suggested answer
    Haque Profile Picture
    3,384 on at
     
    Could you please check if this thread helps?
     
     
    Please let me know.
     
     

    I am sure some clues I tried to give. If these clues help to resolve the issue brought you by here, please don't forget to check the box Does this answer your question? At the same time, I am pretty sure you have liked the response!
  • Suggested answer
    André Arnaud de Calavon Profile Picture
    653 on at
    Hi Jason,
     
    It is possible to loop an Excel file and find the users in Business Central to be disabled using Power Automate flow.
     
    The post shared by Haque talks about using a trigger When a user is updated, but this doesn't exist (anymore). You can create a scheduled flow to list Entra ID users using the Microsoft Graph connector where you can set filters or get attributes if the user is enabled or not. Then list users from BC who are not deactivated.  You can then join the outcomes to have a distinct list of users that needs to be disabled in BC preventing a loop that will be larger and larger.
     
    I don't have experience with the Business Central connector myself, but have created flows using Microsoft Graph and Dynamics 365 F&O together. See: Introducing Dynamics 365 F&O License Automation - Dynamicspedia
  • Suggested answer
    Haque Profile Picture
    3,384 on at
     
    Long before I worked something like this, but things have been changed a lot. I would suggest in the first place to make sure if you have MS Entra ID enabled and all the users are transferred from AD. If so, life would be eays. Let's give a deep dive. Let's see if it helps - steps are given below:


    Step-1:
    Initial Trigger up to you – if you want to run the flow periodically, please select Scheduled cloud flow (will make routine of a timely fashion trigger) or if you want to go on demand – please select Instant clod flow.

    Selecting initial trigger to start the flow: I assuming Scheduled a clod flow will be a good one for you.

    Step-2: We will locate and retrieve the Excel rows, so we will use List rows present in a table action to get all rows from the excel file (Assuming excel file is table formatted). Almost half of you solution is here.

    A parameters filled screenshot is here for your convenience:

    Note: We can use filter query to limit data, such as we can only retrieve rows those are “Blocked” in status.
     
    Step-4: Inside the loop we have some task  here, let's identify them first:
    1. If we have pulled all the rows from the excel (w/o filter), we will loop through (Apply to each) the entire batch, check the condition of the user (if block or not),
    2. If blocked, take the user details to send to BC to disable them using API. Please note that we need to pass the user identifier (such as email or user ID) from the current Excel row to the API.
    3. Once we get the blocked user identifier from the excel file(email), for each row we will get user from the MS Entra ID using endpoint.
    4. Check the user status - Account Enabled (accountEnabled) if true or not. True means the user is still active.
    5. Add an condition to check if Account Enabled (accountEnabled) true, if true, call Update user action from Microsoft Entra ID with the Boolean property to false.

    Note: We need MS Entra ID endpoints to get and update user details.

    Condition: Check if Status is "Blocked"
    • Inside the loop, add a Condition action to check if the "Status" column equals "Blocked."



    If it is blocked, we are going to retrieve the user, in this case you need to use Microsoft Entra ID Get user endpoints


    We need to use Microsoft Entra ID connection reference to call “Get User”. Please read thoroughly API endpoints permissions and support for PowerAutotem.
     
    I just brought up an excerpt here for your reference:
    To use the Microsoft Entra ID connector, the account needs to have the following administrator permissions:
    Group.ReadWrite.All
    User.ReadWrite.All
    Directory.ReadWrite.All



    Signature of the Get User.
     

    As soon as user details are retrieved, we need to check Account Enabled (accountEnabled) property if true or false. Once we find this attribute true means it is still active, we need to disable this, means we need to update the user and make sure  accountEnabled  property is set to false.



    So after retrieving the user, we have added condition if the user is still active, if so we went to update the user using the update user endpoint.

    At the end of the loop, we can send email to the respective administrator mentioning (or attaching the excel file) that respective users have been disabled in the environment.



    There was previous thread in the community – you can pick up some options if you want.


    I am not sure at which level of experience you have in PowerAutomate- if it is mid to expert, then please consider the followings:
    1. The Excel file must have a formatted table for Power Automate to read rows.
    2. We need to make sure that Business Central exposes an API (HTTP) or connector action to disable user accounts programmatically. Some similar discussion is here.
    3. If BC exposes AP, we need to configure OAuth authentication in Power Automate for API calls if we are using HTTP actions.
    4. Let’s consider the batch size of Excel file, If the Excel file has many rows (let’s say more than 500), please consider pagination or batch processing since the List rows present in a table action has limits. I got a very clean help from here. This one is also helpful.
    5. Finally, please don’t forget to add error handling and retribution for robustness.

    At the closure, I will suggest you first build the skeleton and the bit by bit do optimization, error handling.

    Long before I worked with some connectors from D365, but I am not sure if they are deprecated or not.
     
     

    I am sure some clues I tried to give. If these clues help to resolve the issue brought you by here, please don't forget to check the box Does this answer your question? At the same time, I am pretty sure you have liked the response!
     
     
  • Jason Yeung Profile Picture
    53 on at
    Hi all,
     
    Thanks for all your suggestions. It looks like to connect and admin Business Central is done via the Business Central Admin Center API's (Business Central Administration Center API - Business Central | Microsoft Learn).
     
    I had tried to find whether the built in connectors allow accessing the users records, but it doesn't appear to be. Reading and looping through the Excel file is straight forward, I had thought that I could add a Business Central action within the loop to update. But it's not done this way)
     
    I'll do some more investigation on the Admin Center API's to see if I can find the action to put within the loop.
     
    Jason
     
  • Suggested answer
    Haque Profile Picture
    3,384 on at
     
    This thread might help you, specifically JamesTran-MSFT's answer. You might get a clue if HTTP connector can be used with PATCH inside the for each of each excel row.
     
    Thanks.
     
     

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

Season of Sharing Community Challenge Launch!

Jump in, show your community spirit, and win prizes!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Congratulations to the May Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Automate

#1
Vish WR Profile Picture

Vish WR 378

#2
Valantis Profile Picture

Valantis 329

#3
David_MA Profile Picture

David_MA 283 Super User 2026 Season 1

Last 30 days Overall leaderboard