Solved

Parsing the First Initial in PowerShell for Office 365

Posted on 2014-09-18
1
288 Views
Last Modified: 2014-09-18
I’m trying to add email aliases to a new Office 365 setup and I’m using the following script to add firstname.surname:
 
$users1 = Get-Recipient -ResultSize Unlimited| Where {$_.Department -Match “megacorpeurope”}
foreach ($c in $users1) {$c.emailaddresses.Add(“smtp:$($c.FirstName+”.”+$c.LastName)@megacorpeurope.com”)}
$users1 | %{Set-Mailbox $_.Identity -EmailAddresses $_.EmailAddresses}
 
What I also need to add is firstinital.surname@ and firstinitialsurname@, can anyone tell me how I can parse these?  Exchange 2013 says you can use %1g, but I can’t that to work in the above script, I get:
 
Missing property name after reference operator.
    + CategoryInfo          : ParserError: (:) [], ParseException
    + FullyQualifiedErrorId : MissingPropertyName
 
Can anyone help?
 
Thanks
 
Nick
0
Comment
Question by:klaus1013
1 Comment
 
LVL 38

Accepted Solution

by:
Vasil Michev (MVP) earned 500 total points
Comment Utility
$c.FirstName[0] will return the initial.
0

Featured Post

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

Exchange server is not supported in any cloud-hosted platform (other than Azure with Azure Premium Storage).
Not sure what the best email signature size is? Are you worried about email signature image size? Follow this best practice guide.
In this video we show how to create a mailbox database in Exchange 2013. We show this process by using the Exchange Admin Center. Log into Exchange Admin Center.: First we need to log into the Exchange Admin Center. Navigate to the Servers >> Data…
The video tutorial explains the basics of the Exchange server Database Availability groups. The components of this video include: 1. Automatic Failover 2. Failover Clustering 3. Active Manager

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now