Script repository
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
Similar snippet in PowerShell?
Support
What exactly do you mean? The script is already written in PowerShell and can be used in Business Rules, Custom Commands, etc.
Ace
Total beginner in Powershell here. Where do you put the username?
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.