Script repository
The script removes records for deleted objects from a DN-syntax property. To execute the script, create a business rule, custom command or scheduled task configured for the required object type.
In the script, the $propertyName variable specifies the name of the property to update.
$propertyName = "secretary" # TODO: modify me
# Get current property values.
try
{
$values = $Context.TargetObject.GetEx($propertyName)
}
catch
{
$Context.LogMessage("The $propertyName property is empty for %fullname%.", "Information")
return
}
# Remove records for deleted objects.
$newValues = New-Object System.Collections.ArrayList
foreach ($value in $values)
{
if($value -notlike "*DEL:*,CN=Deleted Objects,*")
{
$newValues.Add($value)
}
}
# Update the property
$Context.TargetObject.PutEx("ADS_PROPERTY_UPDATE", $propertyName, @($newValues))
$Context.TargetObject.SetInfo()
Comments 0
You must be signed in to comment.