Solved

Parsing the First Initial in PowerShell for Office 365

Posted on 2014-09-18
1
320 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
[X]
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
1 Comment
 
LVL 41

Accepted Solution

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

Featured Post

Optimizing Cloud Backup for Low Bandwidth

With cloud storage prices going down a growing number of SMBs start to use it for backup storage. Unfortunately, business data volume rarely fits the average Internet speed. This article provides an overview of main Internet speed challenges and reveals backup best practices.

Question has a verified solution.

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

If you troubleshoot Outlook for clients, you may want to know a bit more about the OST file before doing your next job. IMAP can cause a lot of drama if removed in the accounts without backing up.
Check out this step-by-step guide for using the newly updated Experts Exchange mobile app—released on May 30.
This Experts Exchange video Micro Tutorial shows how to tell Microsoft Office that a word is NOT spelled correctly. Microsoft Office has a built-in, main dictionary that is shared by Office apps, including Excel, Outlook, PowerPoint, and Word. When …
Migrating to Microsoft Office 365 is becoming increasingly popular for organizations both large and small. If you have made the leap to Microsoft’s cloud platform, you know that you will need to create a corporate email signature for your Office 365…

717 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