Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

Parsing the First Initial in PowerShell for Office 365

Posted on 2014-09-18
1
306 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 40

Accepted Solution

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

Featured Post

Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Lotus Notes – formerly IBM Notes – is an email client application, while IBM Domino (earlier Lotus Domino) is an email server. The client possesses a set of features that are even more advanced as compared to that of Outlook. Likewise, IBM Domino is…
As cyber crime continues to grow in both numbers and sophistication, a troubling trend of optimization has emerged over the last year.
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…
This Experts Exchange lesson shows how to use VBA to loop through rows in Excel.  In order to sort, filter, and use database features, there needs to be a value in each column for every row. When data arrives with values missing, code to copy values…

828 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