The following forum(s) have migrated to Microsoft Q&A (Preview): Azure Active Directory!
Visit Microsoft Q&A (Preview) to post new questions.

Learn More

 locked
Set-MsolUser -AlternateEmailAddresses issue. RRS feed

  • Question

  • Hi All - Initially I posted my question at http://community.office365.com/en-us/forums/148/p/206113/622010.aspx but was asked to post here.

    The question I have is how to manage 'AlternateEmailAddresses' values using Set-MsolUser cmdlet ?

    I tried 

    1>
    $user = get-msoluser -ObjectId e0b1e7sa-dgd0-47he-fgds-84dfdbaa69cc
    $user.AlternateEmailAddresses += "test2@yahoo.com"
    Set-MsolUser -ObjectId e0b1e7sa-dgd0-47he-fgds-84dfdbaa69cc -AlternateEmailAddresses $user.
    lternateEmailAddresses

    Set-MsolUser :Invalid value for parameter.  Parameter Name: AlternateEmailAddresses.
    At line:1 char:1
    + Set-MsolUser -ObjectId  e0b1e7sa-dgd0-47he-fgds-84dfdbaa69cc -AlternateEmailAddre ...
    + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
        + CategoryInfo          : OperationStopped: (:) [Set-MsolUser], MicrosoftOnlineException
        + FullyQualifiedErrorId : Microsoft.Online.Administration.Automation.PropertyValidationException,Microsoft.Online.

     

    2>

    Set-MsolUser -ObjectId  e0b1e7sa-dgd0-47he-fgds-84dfdbaa69cc -AlternateEmailAddresses @{ADD='
    test1@yahoo.com','test1@gmail.com'}

    Set-MsolUser :Invalid value for parameter.  Parameter Name: OtherMail.
    At line:1 char:1
    + Set-MsolUser -ObjectId e0b1e7sa-dgd0-47he-fgds-84dfdbaa69cc -AlternateEmailAddre ...
    + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
        + CategoryInfo          : OperationStopped: (:) [Set-MsolUser], MicrosoftOnlineException
        + FullyQualifiedErrorId : Microsoft.Online.Administration.Automation.PropertyValidationException,Microsoft.Online.
       Administration.Automation.SetUser

    3>

    $user = get-msoluser -ObjectId e0b1e7sa-dgd0-47he-fgds-84dfdbaa69cc
    $user.AlternateEmailAddresses -= "test1@gmail.com"

    Method invocation failed because [System.Collections.Generic.List`1[[System.String, mscorlib, Version=4.0.0.0,
    Culture=neutral, PublicKeyToken=b77a5c561934e089]]] doesn't contain a method named 'op_Subtraction'.

    At line:1 char:1
    + $user.AlternateEmailAddresses -= "test1@gmail.com"
    + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
        + CategoryInfo          : InvalidOperation: (op_Subtraction:String) [], RuntimeException
        + FullyQualifiedErrorId : MethodNotFound

    Please help. Thanks.


    Tuesday, November 19, 2013 6:04 AM

All replies

  • Hi,

    Currently, you may only set a single alternate email address. (I can see why it would be confusing though, since the parameter is in plural and accepts an array of strings.)

    Philippe

    Tuesday, November 19, 2013 4:42 PM
  • Hi Philippe - Thanks for the reply. I just want to understand this clearly.

    'AlternateEmailAddresses' is actually a multi-valued attribute but because of some bug currently it accepts only 1 value OR it is actually a single-valued attribute but article at http://technet.microsoft.com/en-us/library/dn194136.aspx is incorrect ?

    Which one of the above is correct ?

    Wednesday, November 20, 2013 8:52 AM
  • 'AlternateEmailAddresses' currently only accepts one value. So yes, the TechNet doc could probably be more clear that only a single address is permitted (and the error message could use some improvement as well).

    Could you maybe describe your scenario where you want to add multiple email addresses? Normally, this field is used for admin password recovery. (In Office 365 portal and Azure portal, when a user is set as an admin, you have to give an alternate email address. This is the field that gets changed.)

    Note: using the Graph API, you might able to add multiple email addresses. However, you will no longer be able to change the alternate email address from Office 365 or Azure portals, only through Graph or PowerShell (doing so via PowerShell will drop all the other addresses).

    Philippe

    Wednesday, November 20, 2013 11:03 PM
  • Thanks Philippe again.

    I am developing a c# client using only powershell to manage office 365 users, licenses, security and distribution group memberships, exchange online properties, manage pure security, security+distribution and pure distribution groups... phew...

    Regarding this, I was just checking out each user properties and found the issue. Now I get it, this property will be required only when we create an admin user and not for non-admin users.

    Ok so now - I need to decide to support this attribute or not as there is so much confusion around it (like you said "using the Graph API, you might able to add multiple email addresses. However, you will no longer be able to change the alternate email address from Office 365 or Azure portals, only through Graph or PowerShell (doing so via PowerShell will drop all the other addresses")

    Thursday, November 21, 2013 6:15 AM