Hello,
For information on how to create a Scheduled Task, see the following tutorial: http://www.adaxes.com/tutorials_Automat ... gement.htm. On step 5, add the Run a program or PowerShell script action and paste the following script:
$dirProperty = "adm-CustomAttributeText5" # TODO: modify me
$patern = "^DIR:[0-9]{4}" # TODO: modify me
function UpdateProperty($propertyName, $value)
{
$Context.TargetObject.Put($propertyName, $value)
$Context.TargetObject.SetInfo()
}
# Get all addresses
try
{
$values = $Context.TargetObject.GetEx("proxyAddresses")
}
catch
{
UpdateProperty $dirProperty $NULL
return
}
$numbers = @()
foreach ($value in $values)
{
if ($value -notmatch $patern)
{
continue
}
# Get numbers from address
$numbers += $value.SubString(4, 4)
}
# Update custom attribute
if ($numbers.Length -eq 0)
{
UpdateProperty $dirProperty $NULL
}
else
{
UpdateProperty $dirProperty ($numbers -join ";")
}