Read usernames and email addresses, from CSV

Pete Long
Pete Long used Ask the Experts™
on
Quick one,

If I have a csv file like so

Source-User ,                  Target-Mailbox
usera,                                usera@office365.com
userb,                                userb@office365.com
etc....

And I want to read/loop the users into the following command;

Set-Mailbox -Identity “usera” -DeliverToMailboxAndForward $true -ForwardingSMTPAddress usera@office365.com


What syntax do I use to script that?

Regards

Pete
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Most Valuable Expert 2018
Distinguished Expert 2018
Commented:
Import-Csv -Path "C:\temp\input.csv" | ForEach-Object {
	Set-Mailbox -Identity $_.'Source-User' -DeliverToMailboxAndForward $true -ForwardingSMTPAddress $_.'Target-Mailbox'
}

Open in new window

Pete LongTechnical Consultant

Author

Commented:
Hi oBdA, thanks for the reply, testing........

P
Pete LongTechnical Consultant

Author

Commented:
....Works a treat, ThanQ

Regards

P

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial