After creating a new user I'm modifying the user and setting 2 proxy addresses.
I'm doing this with the build-in modify user functionality.
Our email format is %firstname%.%lastname%@domain1.com
End result looks like
SMTP:%firstname%.%lastname%@domain1.com
smtp:%firstname%.%lastname%@domain2.com
However these values can contain spaces which we don't want.
I've used the following script in the past which works but it doesn't work for the proxyAddresses field. Probably because it has multiple values.
$spacesRemoved = $False
#
if ($Context.IsPropertyModified("ProxyAddresses"))
{
$proxyAddresses = $Context.GetModifiedPropertyValue("ProxyAddresses")
if ($proxyAddresses.Contains(" "))
{
# Remove spaces
$proxyAddresses = $proxyAddresses.Replace(" ", "")
# Update proxyAddresses
$Context.SetModifiedPropertyValue("ProxyAddresses", $proxyAddresses)
$spacesRemoved = $True
}
}
# Log a message
if ($spacesRemoved)
{
$Context.LogMessage("Spaces have been removed from the proxyAddresses",
"Information")
}
So to clarify, we set multiple proxy addresses when creating a user.
Does anybody have an idea to get this working, i'm not as Powershell wizzard...