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.

Script Repository

Remove Direct Reports from manager

The following script can be used in business rules, scheduled tasks and custom commands to remove all Direct Reports from the user on which the script is executed.

To run the script as a part of a rule, command or task, use the Run a program or PowerShell script action.
Edit Remove
    $subordinateDNs = $Context.TargetObject.GetEx("directReports")
    return # The user has no direct reports

foreach($subordinateDN in $subordinateDNs)
    # Clear 'Manager' property of the direct report
    $subordinate = $Context.BindToObjectByDN($subordinateDN)
    $subordinate.Put("manager", $NULL)

Comments 4
Gnana Oct 15, 2018
Similar snippet in PowerShell?
Support Oct 15, 2018
What exactly do you mean? The script is already written in PowerShell and can be used in Business Rules, Custom Commands, etc.
Ace May 12, 2023
Total beginner in Powershell here. Where do you put the username?
Support May 12, 2023

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.
Leave a comment

Got questions?

Support Questions & Answers