Script repository
The script removes values matching a regular expression from a multi-valued property. To execute the script, create a business rule, custom command or scheduled task configured for the required object type.
Parameters
$property- the name of the multi-valued property you want to remove values from.$regex- the regular expression to use when removing values.
$property = "proxyAddresses" # TODO: modify me
$regex = "^smtp:[a-zA-Z0-9_.%%\-\+]+@example\.com$" # TODO: modify me
$values = $Context.TargetObject.GetEx($property)
$valuesToRemove = @()
foreach ($value in $values)
{
if ($value -cnotmatch $regex)
{
continue
}
$valuesToRemove += $value
}
if ($valuesToRemove.Length -eq 0)
{
return
}
# Update the target object.
$Context.TargetObject.PutEx("ADS_PROPERTY_DELETE", $property, $valuesToRemove)
$Context.TargetObject.SetInfo()
Comments 0
You must be signed in to comment.