Script repository
The script sets the owner of the Organizational Unit where a user account is located as the user manager. To execute the script, create a business rule, custom command or scheduled task configured for the User object type.
# Bind to the OU where the user is located
$parent = $Context.BindToObject($Context.TargetObject.Parent)
try
{
# Get the owner's DN
$managerDN = $parent.Get("managedBy")
}
catch
{
$Context.LogMessage("Cannot update a manager for the user because the user's Organizational Unit is not managed by anyone", "Warning") # TODO: modify me
return
}
# Set manager
$Context.TargetObject.Put("manager", $managerDN)
$Context.TargetObject.SetInfo()
Comments 0
You must be signed in to comment.