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 Automate - Building Flows
Answered

Create on-premises Active Directory user with Flow

(0) ShareShare
ReportReport
Posted on by 40

Hi!

 

What would you suggest as a best workaround to create new user in on-premises Active Directory with Microsoft Flow? I understand that there is no direct connector in Flow to connect to on-premises AD but would for example On-Premises gateway or something like that be a solution for this?

 

Our target is to automate new employee process as much as possible.

 

Best regards,

Toni Rantanen

I have the same question (0)
  • kuingul Profile Picture
    2 on at
    Re: Create on-premises Active Directory user with Flow

    If you need automation for AD user provisioning, I believe you should be looking at 3rd party solutions that specialize in AD automation. Here's a good example of a solution for that: https://www.adaxes.com/active-directory_provisioning.htm

  • Verified answer
    v-yamao-msft Profile Picture
    on at
    Re: Create on-premises Active Directory user with Flow

    Hi @ToniRantanen,

     

    Currently, Microsoft flow doesn’t support On-Premise Active Directly, only On-Premise SharePoint and On-Premise SQL Server are supported.

     

    If you need this feature, please submit an idea on the Flow Ideas Forum:

    https://powerusers.microsoft.com/t5/Flow-Ideas/idb-p/FlowIdeas 

     

     

    Best regards,

    Mabel Mao

  • ToniRantanen Profile Picture
    40 on at
    Re: Create on-premises Active Directory user with Flow

    Thanks @v-yamao-msft, I submitted the idea (https://powerusers.microsoft.com/t5/Flow-Ideas/Support-for-on-premise-Active-Directory/idi-p/135567 - please vote Smiley Wink).

  • ToniRantanen Profile Picture
    40 on at
    Re: Create on-premises Active Directory user with Flow

    Hi @kuingul,

     

    Is it possible to trigger Adaxes Active Directory Provisioning with Microsoft Flow? I'm looking for a solution where for example HR would fill new employee's details to Microsoft Forms and then Microsoft Flow would take care rest of the routine tasks related to new employee start.

     

    Best regards,

    Toni Rantanen

  • CrankyNetGuy Profile Picture
    22 on at
    Re: Create on-premises Active Directory user with Flow

    I have created a way to trigger the creation of an AD User with the help of a gateway.

     

    I have a list in Sharepoint when HR submits a new user. It takes those values and compiles it into a csv with the necessary fields required in powershell.

     

    Once the csv is created I send it to my on-prem server with the gateway to a specific folder. I have a repeating task in task scheduler set to run a .bat which calls a powershell script to monitor the folder indefinitely. That powershell script will monitor that folder for any file ending in ".csv" being created. When it triggers it sets off my CreateUser.ps1 which will import the newly created csv and create the user based on that. Once the script is ran, due to the way I'm importing the csv, it will delete that csv from the folder (I had the flow create the csv in a sharepoint docs folder as backup as well).

     

    I hope I explained that well.

  • Community Power Platform Member Profile Picture
    on at
    Re: Create on-premises Active Directory user with Flow

    Would you mind sending me the script that you used to do that? I've been thinking through this problem today - and I think this might be the best solution tbh. Great idea!

     

    Were you able to take unique passwords for the users or were they all the same password for each user created? 

  • CrankyNetGuy Profile Picture
    22 on at
    Re: Create on-premises Active Directory user with Flow

    I was able to create a unique password for each user. When creating the csv I used a randomly generated GUID and grabbed the first x number of characters and set that for the password field.

     

    The script to monitor is fairly simple:

     

    $folder = # Enter the root path you want to monitor. 
    $filter = '*.csv' # You can enter a wildcard filter here. 
    
    $fsw = New-Object IO.FileSystemWatcher $folder, $filter -Property @{IncludeSubdirectories = $false;NotifyFilter = [IO.NotifyFilters]'FileName, LastWrite'}
    
    Register-ObjectEvent $fsw Created -SourceIdentifier FileCreated -Action { 
    
    Invoke-Item 'Folderpath.bat'
    }

     

    Since I am not logged onto a server 100% of the time I set a task schedule to call a .bat which will open up this script with a persistent window (as it requires an active PS window). That is done with a .bat (ran every 5 minutes through Event Scheduler to ensure it stays up)

     

    Powershell.exe -noexit "& "Path.ps1

    The "Folderpath.bat" mentioned in the first block of code with "Invoke-Item" is what invokes this 

    Powershell.exe -executionpolicy remotesigned -File Path-To-Create-User.ps1

    That .ps1 is my create AD user script. You can find plenty of guides on how to customize that to your needs. The important parts (for this method anyway) is that you need it to run right as the .csv is entered and then delete the .csv as it pulls every csv in the folder. I'm sure you could do a foreach but I'm too lazy for that and this works perfectly fine as I have a backup of the csv in a SharePoint drive.

     

    Just start the create-user.ps1 like this:

    Import-Module ActiveDirectory
    
    $CSVPath = Get-ChildItem C:\Path-To-Folder-With-CSV -Filter *.csv | select -ExpandProperty FullName
    $User = Import-Csv -Delimiter "," -Path $CSVPath

    And do a 

    Remove-Item -Path $CSVPath

    To delete the csv that was just created.

     

    I hope that is clear enough to follow, I'd be happy to clarify or help further if I can.

  • Community Power Platform Member Profile Picture
    on at
    Re: Create on-premises Active Directory user with Flow

    Thank you so much!! This is great. 

     

    Do you know how you ensure that a csv isn't deleted in the case of 2 simultaneous users created in the SharePoint form? 

     

    How do you make sure it only deletes the csv for the user you just created? 

  • CrankyNetGuy Profile Picture
    22 on at
    Re: Create on-premises Active Directory user with Flow

    At least in my situation only one user can be submitted at a time so the CSV will only be created for a single user. Since the script runs right when the csv is put into the folder you'd have to have 2 users submitted something at exactly the same second which is highly unlikely. If you can control the situation I would highly recommend only one user per form.

     

    For deleting the csv you just created that will be with the $CSVPath variable as that is what it imports from.

  • pobblebonk Profile Picture
    2 on at
    Re: Create on-premises Active Directory user with Flow

    Hi,

    You should be able to use powershell CSOM scripting using a package like PnP-PowerShell to wathc the sharepoint list and update the list item status once processed and also provide direct feedback if there were any issues.

     

    Hope this helps.

    Mat

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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Chiara Carbone – Community Spotlight

We are honored to recognize Chiara Carbone as our Community Spotlight for November…

Leaderboard > Power Automate

#1
Michael E. Gernaey Profile Picture

Michael E. Gernaey 659 Super User 2025 Season 2

#2
Tomac Profile Picture

Tomac 386 Moderator

#3
chiaraalina Profile Picture

chiaraalina 290

Last 30 days Overall leaderboard