Setting up Auto forwarding for users in CSV

Abdullah Tahir khan 61 Reputation points
2021-02-18T05:40:21.99+00:00

Hi there, By using PowerShell, I want to setup auto forwarding for users whose details saved in a csv file to their new email Address. CSV file will be like this: User Principal Old Email Address New Email Address Name User 1 User1 Old email address User1 New email address User 2 User2 Old email address User2 New email address How can I make it possible. please help,

Exchange Exchange Server Management
{count} votes

Accepted answer
  1. Ashok M 6,846 Reputation points
    2021-02-18T07:16:15.673+00:00

    Hi @Abdullah Tahir khan ,

    Please prepare the csv like the below and save it as useremail.csv

    69350-image.png

    Command to forward to user in same Exchange,
    Import-csv useremail.csv | foreach-object {Set-Mailbox -Identity $.Name -ForwardingAddress $.NewEmail}

    If the mails needs to be delivered to both the mailboxes, use the below command,

    Import-csv useremail.csv | foreach-object {Set-Mailbox -Identity $.Name -ForwardingAddress $.NewEmail -DeliverToMailboxAndForward $true}

    If the mails needs to be delivered to external email, use the below command,

    Import-csv useremail.csv | foreach-object {Set-Mailbox -Identity $.Name -ForwardingSMTPAddress $.External}

    If the mails needs to be delivered to both the user mailbox and external email, use the below command,

    Import-csv useremail.csv | foreach-object {Set-Mailbox -Identity $.Name -ForwardingSMTPAddress $.External -DeliverToMailboxAndForward $true}

    You can verify it using,

    Get-Mailbox -Identity user1 | fl ForwardingAddress,ForwardingSMTPAddress,DeliverToMailboxandForward

    If the above suggestion helps, please click on "Accept Answer" and upvote it.


0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.