Run Powershellscript immediatly after user creation

Andy 41 Reputation points
2025-02-03T15:30:51.1066667+00:00

Is there a way to start a Powershell script directly after creating an AD user? So that the script is triggered, so to speak, by the “AD user created” action/event. However, I don't mean the event that occurs in the event log. I also don't like the detour using scheduled tasks. I would like to trigger the script directly after creating the user (e.g. to set a few standard AD groups).

Windows for business Windows Client for IT Pros Directory services Active Directory
Windows for business Windows Server User experience PowerShell
0 comments No comments
{count} votes

Accepted answer
  1. Martin Brandl 545 Reputation points MVP
    2025-02-03T15:36:22.8166667+00:00

    There’s no direct, native way in AD to trigger a PowerShell script immediately upon user creation without using some form of external monitoring or integration. The most straightforward solution is to incorporate the script call into your user creation process (if not present, you might think about setting it up).

    1 person found this answer helpful.
    0 comments No comments

2 additional answers

Sort by: Most helpful
  1. Rich Matheisen 47,901 Reputation points
    2025-02-03T21:02:27.6533333+00:00

    3rd-party software. Adaxes (adaxes.com), or ADManager Plus (https://www.manageengine.com). There may be others. Those products expect you to use their software to create the users, though.

    Are you using just AD Users and Computers to create those users, or are you using your own script? If it's your script, just incorporate the process into your script. Probably the best way would to be to create a script module and load the module wherever you need it (or let PowerShell auto-load it if it's in one of the module directories).

    @Martin Brandl has the right idea.

    1 person found this answer helpful.
    0 comments No comments

  2. Anonymous
    2025-02-05T04:02:44.0966667+00:00

    Hi Andy,

    You can create a scheduled task triggered by the event 4720.

    In the Triggers tab, set the Log to Security, Source to Microsoft Windows security auditing, and Event ID to 4720.

    User's image

    In the Actions tab, you can run the specified PowerShell script.

    User's image

    https://learn.microsoft.com/en-us/previous-versions/windows/it-pro/windows-10/security/threat-protection/auditing/event-4720

    Best Regards,

    Ian Xue


    If the Answer is helpful, please click "Accept Answer" and upvote it.

    0 comments No comments

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.