0 votes

Hallo,
In the deprovisioning process we add "_" to each email addresses like you see on below script:

# Get mailbox parameters
$mailboxParams = $Context.TargetObject.GetMailParameters()

# Change email adresses
$mailboxParams.EmailAddressPolicyEnabled = $False
$emailAddresses = $mailboxParams.EmailAddresses
for ($i = 0; $i -lt $emailAddresses.Count; $i++)
{
    $emailAddress = $emailAddresses.GetAddress($i,[ref]"ADS_PROPERTY_NONE")
    $emailAddress.Address = "_" + $emailAddress.Address
}
$mailboxParams.EmailAddresses = $emailAddresses

But sometimes we have user has X400 an X500 addresses we would like to remove those addresses, how can I do it using Adaxes SDK?

by (510 points)

1 Answer

0 votes
by (216k points)
selected by
Best answer

Hello,

Like this:

$prefixes = @("x400", "x500") # TODO: modify me

# Get mailbox parameters
$mailboxParams = $Context.TargetObject.GetMailParameters()

# Remove Address with the specified prefixes
$mailboxParams.EmailAddressPolicyEnabled = $False
$emailAddresses = $mailboxParams.EmailAddresses
foreach ($prefix in $prefixes)
{
    foreach ($emailAddress in $emailAddresses.GetAddressesByPrefix($prefix))
    {
        $emailAddresses.Remove($emailAddress)
    }
}

# Change email addresses
for ($i = 0; $i -lt $emailAddresses.Count; $i++)
{
    $emailAddress = $emailAddresses.GetAddress($i,[ref]"ADS_PROPERTY_NONE")
    $emailAddress.Address = "_" + $emailAddress.Address
}
$mailboxParams.EmailAddresses = $emailAddresses

# Save changes
$Context.TargetObject.SetMailParameters($mailboxParams, "ADM_SET_EXCHANGE_PARAMS_FLAGS_NONE")
0

And what if I'd like to change only SMTP addresses, without any changes on X500 and X400?
I mean we add "_" to all SMTP but left X400 and X500 without ant chanes.

0

Sure:

# Get mailbox parameters
$mailboxParams = $Context.TargetObject.GetMailParameters()

# Change SMTP email addresses
$mailboxParams.EmailAddressPolicyEnabled = $False
$emailAddresses = $mailboxParams.EmailAddresses
foreach ($emailAddress in $emailAddresses.GetAddressesByPrefix("SMTP"))
{
    $emailAddress.Address = "_" + $emailAddress.Address
}
$mailboxParams.EmailAddresses = $emailAddresses

# Save changes
$Context.TargetObject.SetMailParameters($mailboxParams, "ADM_SET_EXCHANGE_PARAMS_FLAGS_NONE")

Related questions

0 votes
1 answer

We have been able to add email addresses using the script in E-Mail Addresses Is there a way to reverse the process and specify the smtp address you want to remove using a similar subset of code.

asked Dec 14, 2022 by martin.mcclorey (40 points)
0 votes
1 answer

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%. ... anybody have an idea to get this working, i'm not as Powershell wizzard...

asked Oct 15, 2018 by Quinten (100 points)
0 votes
1 answer

Hi All, I am looking for a script i can use in adaxes, that removes all delegates for an exchange O365 mailbox, and reset their MFA tokens as well. I ... ($mailbox.Identity)" } } } # Disconnect from Exchange Online Disconnect-ExchangeOnline -Confirm:$false

asked Apr 18 by Brobertson92594 (20 points)
0 votes
1 answer

Hello All, is is possible via Adaxes deprovisioning to remove all his Azure and M365 roles besides custom Powershell script? Regards Ivaylo

asked Mar 31, 2023 by ivaylo.valkov (100 points)
0 votes
1 answer

I want to remove special characters on the onboarding web form for username and mail before clicking Finish. Using a script like on the rule "Before User Creation" seems to to do the change to late and you can not verify the email adress before created.

asked Dec 27, 2021 by joem (20 points)
3,351 questions
3,052 answers
7,794 comments
545,113 users