Script Repository


Remove Direct Reports from manager

October 01, 2015
2720

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
October 15, 2018

Similar snippet in PowerShell?

avatar
Support
October 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