Quantcast
Channel: PowerShell.com – PowerShell Scripts, Tips, Forums, and Resources
Viewing all articles
Browse latest Browse all 6937

request for Script for enable-mailbox with conditional SMTP

$
0
0

Hi Tech gurus,

I have scenario, wherein if I have a user Firstname.Lastname@company.com in org and another same Firstname.Lastname comes in.. instead of Firstname.Lastname2@company.com. I would like to use middle name initial, and make it Firstname.FirstletterInitial.Lastname@company.com. In case no middle name is mentioned it should pick Firstname.Lastname@company.com

Also, rest of the EmailAddressPolicyEnabled should be true and applicable.

I would like to enable it for existing AD object under enable-mailbox.

Can you please guide me for the same.

So far I built :

$sam = $_.samAccount

$givenName = $_.GivenName

$Initial = $_.Initials

$LastName = $_.LastName

$EmailAddress = ($givenName+$Initial+$LastName+"@company.com")

Enable-Mailbox -Identity $sam -PrimarySmtpAddress $EmailAddress -Database DB2 | Set-Mailbox -IgnoreDefaultScope -EmailAddressPolicyEnabled $true -Identity $sam


Viewing all articles
Browse latest Browse all 6937

Trending Articles