Need to change multiple Aiases in Exchange using a .csv, can't make it work

Jon 96 Reputation points
2021-10-26T10:39:54.353+00:00

Hi,

I really hope someone can assist here as Exchange Shell is not my forte!

All I need to do is change a load of Aliases in Exchange using a .csv - The two columns in the .csv are Mail and Alias. I can change a single one using the command set-mailbox XXX.XXX@X .com -alias AB123.

As soon as I import the .csv either importing it separately or importing it in the same command line, everything errors horribly.

Does anyone have any idea what I can run to get this working? I've tried quite a few things:

Import-csv "c:\scripts\aliases.csv" | foreach {Get-MailContact -Identity $.Name | Set-MailContact -Alias $.Alias}

[PS] C:\Windows\system32>$csv= "C:\scripts\aliases.csv"
[PS] C:\Windows\system32>foreach ($mailbox in $csv) {get-mailbox -identity $mailbox.Mail | set-mailbox -alias $mailbox.Alias}

ANY help here would be greatly appreciated!

Microsoft Office Online Server
Microsoft Office Online Server
Microsoft on-premises server product that runs Office Online. Previously known as Office Web Apps Server.
581 questions
{count} votes

Accepted answer
  1. Jon 96 Reputation points
    2021-10-26T11:38:59.643+00:00

    Ok, so this is embarrassing but at least I learnt something!

    It appears the issue was with the .csv, even though I had checked it before copying it to the server, it was blank and also had the wrong column names in it, I know, weird and makes no sense!

    I would have thought I was going crazy if it was not witnessed by a colleague!

    So, after checking the .csv on the server, importing it and running the code, it worked!

    143806-image.png

    0 comments No comments

0 additional answers

Sort by: Most helpful