I wrote a program to update AlternateEmail of some users in Office 365. I created a csv import file, and run this through the following lines:
Import-Csv -path "users.csv.txt" -Delimiter ";" | foreach {
$m = $_.AlternateEmailAddresses
$e = $_.EmailAddress
$w = "set-MSOlUser -UserPrincipalName $e -AlternateEmail $m" # there is no -whatif, so to test before running, do a write-host $w
if [$m -ne ""] {
set-MSOlUser -UserPrincipalName $e -AlternateEmail $m
}
}
It did run almost right with the input of 500 users. There was just one error:
[blockquote]set-MSOlUser : Invalid value for parameter. Parameter Name: OtherMail.
At line:7 char:9
-
set-MSOlUser -UserPrincipalName $e -AlternateEmail $m -
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~- CategoryInfo : OperationStopped: [:] [Set-MsolUser], MicrosoftOnlineException
- FullyQualifiedErrorId : Microsoft.Online.Administration.Automation.PropertyValidationException,Microsoft.Online.Administration.Automa
tion.SetUser
[/blockquote]
Just one line in de input line is wrong, only which one ? It would be very helpful if the full line is outputted with expanded variables. I could use -verbose, but that will result in a lot of logging. I just want the complete line where the error occurred, not all those lines where it goes well.
How can I accomplish this easily ? Is there some extra debug option I don’t know of ?