Script repository

Remove direct reports from user

Updated on: Jan 18, 2026, Views: 12235

Approval requests

The script removes all direct reports from the target user. It can be executed in business rules, scheduled tasks and custom commands configured for thre User object type.

# Get user subordinates.
try
{
    $subordinateDNs = $Context.TargetObject.GetEx("directReports")
}
catch
{
    $Context.LogMessage("User %fullname% has no direct reports.", "Warning")
    return
}

foreach($subordinateDN in $subordinateDNs)
{
    # Clear the 'manager' property.
    $subordinate = $Context.BindToObjectByDN($subordinateDN)
    $subordinate.Put("manager", $NULL)
    $subordinate.SetInfo()
}

Comments 4

You must be signed in to comment.

  • Gnana

    Gnana

    Similar snippet in PowerShell?

    • Support

      Support

      What exactly do you mean? The script is already written in PowerShell and can be used in Business Rules, Custom Commands, etc.

  • Ace

    Ace

    Total beginner in Powershell here. Where do you put the username?

    • Support

      Support

      Hello,

      There is no need to enter the username anywhere. As it is mentioned in the script description, it should be executed in a custom command, business rule or scheduled task configured for the User object type. It will automatically work for the target user. The script is dedicated for Adaxes and will not work in Windows PowerShell.

Got questions?

Support Questions & Answers

We use cookies to improve your experience.
By your continued use of this site you accept such use.
For more details please see our privacy policy and cookies policy.