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
PowerShell
try
{
    $subordinateDNs = $Context.TargetObject.GetEx("directReports")
}
catch
{
    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)
    $subordinate.SetInfo()
}

Comments 4
avatar
Gnana Oct 15, 2018
Similar snippet in PowerShell?
avatar
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.
avatar
Ace May 12, 2023
Total beginner in Powershell here. Where do you put the username?
avatar
Support May 12, 2023
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.
Leave a comment
Loading...

Got questions?

Support Questions & Answers