I need to add extra smtp proxy addresses to my clients because I am trying to standardise emails in my organisation. At present it a bit hit and miss. Because of this I want to add in bulk. I thought I would do this in powershell using the following.

$Users = Import-csv C:\tmp\proxytry.csv $Users | ForEach {Set-Mailbox $_.UserID -EmailAddresses $_.NewAddress,$_.UserID,$_.Proxy1}

However I am getting this error

[PS] C:\>$Users = Import-CSV C:\tmp\proxytry.csv $User | ForEach {Set-Mailbox $_.UserID -EmailAddresses $_.NewAddress,$_.UserID,$_.Proxy1}
Import-Csv : Cannot validate argument on parameter 'Delimiter'. The argument is null. Provide a valid value for the argument, and then try running the command again.
At line:1 char:41
+ $Users = Import-CSV C:\tmp\proxytry.csv $User | ForEach {Set-Mailbox $_.UserID - ...
+                                         ~~~~~
    + CategoryInfo          : InvalidData: (:) [Import-Csv], ParameterBindingValidationException
    + FullyQualifiedErrorId : ParameterArgumentValidationError,Microsoft.PowerShell.Commands.ImportCsvCommand

This is an example of the csv I am using

UserID	NewAddress	Proxy1
John@office 365.com	John@office 365.com	John@midorg.com
alice@office 365.com	alice@office 365.com	alice@midorg.com

All this info came from this site Manage Email address using PowerShell | Office 365 - o365info however it seems a long time since anyone used it.
Can anyone point me in the right direction.

2 Spice ups

A quick look at the error… invalid delimiter… makes me think it wants a comma or semicolon, not a space / tab, between accounts.

Thanks for the reply

I have just tried a comma, semicolon, tab and space all with the same results

Looking at your sample again… you don’t actually have spaces before 365.com, do you?

John@office 365.com should be John@office365.com

Are you running all of that on a single line? What you posted looks like it should be two lines of code.

$Users = Import-csv C:\tmp\proxytry.csv
$Users | ForEach {Set-Mailbox $_.UserID -EmailAddresses $_.NewAddress,$_.UserID,$_.Proxy1}

The error message is occurring because -Delimiter is the second positional parameter and it’s trying to place $Users into it. Since $Users at that point is null it throws the error message you’re seeing.

3 Spice ups

Gungnir you were correct I was running it all together.

It now runs fine, although I have given myself a new issue to sort out I have legacy exchange attributes to sort out.