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

Got questions?

Support Questions & Answers