0 votes

I am using adm-CustomAttributeText2 to capture external email address. And then using the same to create mail enabled exchange account. But I would like to restrict the external email address to around 70 odd approved domains. So nobody can just enable any account for mail enabled feature for other unknown public email domains. How do I compare this attribute with a csv list of email domains and if domain is in the list only then enable & send an email on success. Else reject with a friendly error message on the web page.

$exchangeServer = "ex01" 
# Connect to Exchange Server
$session = New-PSSession -Configurationname Microsoft.Exchange –ConnectionUri http://$exchangeServer/powershell
Import-PSSession $session -DisableNameChecking -AllowClobber
# Enable Mail User
Enable-MailUser "%distinguishedName%" -ExternalEmailAddress %adm-CustomAttributeText2%
Set-MailUser "%distinguishedName%" -EmailAddressPolicyEnabled $false
$PrimaryEmail = (Get-MailUser "%distinguishedName%"|  select -ExpandProperty emailaddresses | where{$_ -like "*@hello.com"}) -replace "Smtp:"
Set-MailUser "%distinguishedName%" -PrimarySMTPAddress $PrimaryEmail
Set-MailUser "%distinguishedName%" -EmailAddressPolicyEnabled $true
# Close connection to Exchange Server
Remove-PSSession $session
by (460 points)

Please log in or register to answer this question.

Related questions

0 votes
1 answer

I'm learning the Adaxes powershell methods for creating objects. I would like to create a contact that is mail enabled. I attempted to use the example but it failed ... example of how to create a mail enabled contact with PowerShell using the New-AdmObject?

asked Jul 29, 2020 by ComputerHabit (790 points)
0 votes
1 answer

I've got the following script as part of a larger piece where param-members is an AD Object picker list seperated by a ' ; ' currently: New-DistributionGroup -Name ... or convert that to username but I'm struggling to achieve that with multiple Users selected

asked Jan 27, 2020 by richarddewis (240 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)
0 votes
1 answer

Hi- When I attempt to set this up, in my drop box, I have "no pools found" and is unable to enter the pool. Why can't I enter the pool or what has to happen in order for Adaxes to see that we have pools available?

asked May 29, 2014 by MeliOnTheJob (1.7k points)
0 votes
1 answer

Hi, I found where to show enabled users only in the group membership window, but when we export the content of the group, it also exports disabled users. Is there a way to export ... we don't want them to show in the exports as it will create noise... Thanks.

asked Dec 7, 2020 by fl001860 (40 points)
2,779 questions
2,512 answers
6,574 comments
25,904 users