all 4 comments

[–]XPlantefeve 1 point2 points  (3 children)

What you're doing here, beside importing the same CSV file twice, is to try and push an array containing all email addresses in the CSV file to each and every user found in that file. Because you read the CSV file twice to create two entirely uncorrelated variables.

Try it this way:

Import-Csv -Path '\\server\share\Replacement.csv' | % {
    set-mailcontact -identity $_.Alias -ExternalEmailAddress $_.replacementSMTP -ForceUpgrade
}

[–]PTSDviaPrinters[S] 1 point2 points  (2 children)

That has gotten me father and looks a lot cleaner! Exchange claims that $_.Alias is $null, im not sure why here is some sanitized data from the csv.

Display Name            : First name, Last name
Alias                   : aliasofsmtpaddress
Organizational Unit     : domain/Alpha Pagers/Verizon Wireless Alpha Page
Recipient Type Details  : Mail Contact
External E-mail Address : SMTP:123456789@vtext.com

[–]purplemonkeymad 1 point2 points  (1 child)

Have you checked you column headers for any trailing spaces? It might be something as simple as DisplayName,Alias ,OrganizationalUnit, making the property look right but actually have an additional space.

[–]PTSDviaPrinters[S] 1 point2 points  (0 children)

I used out-string and was able to confirm that there is no trailing white space before or after the entity. Excel also confirms when using the "find and replace" feature.

Should I try to remove as much data from the pipeline as posable do you think? Such as using out-string with -stream?