Solved

Parsing the First Initial in PowerShell for Office 365

Posted on 2014-09-18
1
300 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 39

Accepted Solution

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

Featured Post

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

Cloud-based technologies and services will continue to grow in popularity in 2017 thanks to the simple, scalable and cost-effective solutions they deliver. Here are three areas where cloud adoption is poised to really take off.
The following article is intended as a guide to using PowerShell as a more versatile and reliable form of application detection in SCCM.
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
In this video I am going to show you how to back up and restore Office 365 mailboxes using CodeTwo Backup for Office 365. Learn more about the tool used in this video here: http://www.codetwo.com/backup-for-office-365/ (http://www.codetwo.com/ba…

806 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