none
set-mailbox EX2010 fails when SamAccountName has spaces

    Question

  •  

    Dear.

    I'm facing an issue with the EX2010  set-mailbox command. It fails on users who have a space in their SamAccountName in Active Directory.

    The point is that I don’t even use the SamAccountName. I use the mail address for the –identity parameter. But it seems that the set-mailbox uses the SamAccountName in the background.

    Anyone an idea how to overcome this situation? Renaming the SamAccountName is not an option.

    Thanks in advance,
    Regards,
    Peter


    Peter Van Keymeulen, IT Infrastructure Solution Architect, www.edeconsulting.be

    Thursday, March 01, 2012 10:33 AM

All replies

  • Hi Peter

    If you specify the SamAccountName in speech marks (e.g. "name surname") does the Set-Mailbox command work?

    Cheers, Steve

    Thursday, March 01, 2012 10:44 AM
  • Steve.

    We don't even use the SanAccountName, it's the command itself that uses it somewhere in the background. This is the command we use:

    Set-mailbox -identity $email -EmailAddressPolicyEnabled:$false -UseDatabaseQuotaDefaults:$false -IssueWarningQuota $NEW_mDBStorageQuota -ProhibitSendQuota $NEW_mDBOverQuotaLimit -ProhibitSendReceiveQuota $NEW_mDBOverHardQuotaLimit

    The error:

     

    Set-Mailbox : Property expression "Hvan Laa" isn't valid. Valid values are: Strings formed with characters from A to Z

    (uppercase or lowercase), digits from 0 to 9, !, #, $, %, &, ', *, +, -, /, =, ?, ^, _, `, {, |, } or ~. One or more pe

    riods may be embedded in an alias, but each period should be preceded and followed by at least one of the other charact

    ers. Unicode characters from U+00A1 to U+00FF are also valid in an alias, but they will be mapped to a best-fit US-ASCI

    I string in the e-mail address, which is generated from such an alias. Property Name: Alias

    At D:\_Pilot\migration\Move_MailBoxes.ps1:304 char:16

    +     Set-mailbox <<<<  -identity $email -EmailAddressPolicyEnabled:$false -UseDatabaseQuotaDefaults:$false -IssueWarni

    ngQuota $NEW_mDBStorageQuota -ProhibitSendQuota $NEW_mDBOverQuotaLimit -ProhibitSendReceiveQuota $NEW_mDBOverHardQuotaL

    imit

        + CategoryInfo          : NotSpecified: (internal.vodafo...ny.vanLaarhoven:ADObjectId) [Set-Mailbox], DataValidati

       onException

        + FullyQualifiedErrorId : 54893833,Microsoft.Exchange.Management.RecipientTasks.SetMailbox

    peter


    Peter Van Keymeulen, IT Infrastructure Solution Architect, www.edeconsulting.be

    Thursday, March 01, 2012 11:13 AM
  • The script stops on this error. Is there a way to keep the script ongoing, even if it faces this error. The script should continue with the next user.

    Peter Van Keymeulen, IT Infrastructure Solution Architect, www.edeconsulting.be

    Thursday, March 01, 2012 12:18 PM
  • Hi Peter

    To get it to skip the error you should be able to add the following onto the end of your script: -ErrorAction continue

    Having said that your script should continue anyway.  Are you running this as a foreach loop and where are you specifying the variables?

    Cheers, Steve

    Thursday, March 01, 2012 1:22 PM
  • Steve.

    It's a foreach loop with data comming from an SQL database:

    foreach ($row in $DataSet.Tables[0].Rows)

    {
        $mailboxID=$row[0].ToString()
        $email=$row[1].ToString()
        $NewHomeMDB=$row[2].ToString()
        $NEW_mDBStorageQuota=$row[3].ToString()
        $NEW_mDBOverQuotaLimit=$row[4].ToString()
        $NEW_mDBOverHardQuotaLimit=$row[5].ToString()
        
        Set-mailbox -identity $email -EmailAddressPolicyEnabled:$false -UseDatabaseQuotaDefaults:$false -IssueWarningQuota $NEW_mDBStorageQuota -ProhibitSendQuota $NEW_mDBOverQuotaLimit -ProhibitSendReceiveQuota $NEW_mDBOverHardQuotaLimit   
    }


    Peter Van Keymeulen, IT Infrastructure Solution Architect, www.edeconsulting.be

    Thursday, March 01, 2012 2:02 PM
  • Can you  change the script to show the data that is coming in from the table, I want to see exactly what it is running.

    I made a test account with a space in the SAMAccountName and am not getting what you have above:

    PS C:\> Get-ADUser "user 1"

    DistinguishedName : CN=user 1,OU=Punters,DC=DOM2K8R2EX14,DC=lab
    Enabled           : True
    GivenName         : user 1
    Name              : user 1
    ObjectClass       : user
    ObjectGUID        : 286c1cbf-2dcc-4468-aa9e-40d6cd0a916b
    SamAccountName    : user 1
    SID               : S-1-5-21-3130637666-1297956054-559513024-1127
    Surname           :
    UserPrincipalName : user 1@DOM2K8R2EX14.lab

    Then I made the following, based off what you were running and saved it as a .ps1.   

    $email =  "user1@dom2k8r2ex14.lab"
    $NEW_mDBStorageQuota =  1024
    $NEW_mDBOverQuotaLimit = 2048
    $NEW_mDBOverHardQuotaLimit =  4096

     

    Set-mailbox -identity $email -EmailAddressPolicyEnabled:$false -UseDatabaseQuotaDefaults:$false -IssueWarningQuota

    $NEW_mDBStorageQuota -ProhibitSendQuota $NEW_mDBOverQuotaLimit -ProhibitSendReceiveQuota $NEW_mDBOverHardQuotaLimit

     


    Cheers, Rhoderick

    Thursday, March 01, 2012 3:30 PM
  • Hi Peter,

    Any updates?

    Please try to run a simple "Set-Mailbox" cmdlet against the specific mailbox, what's the result?

    For example:

    Set-Mailbox "user" -CustomAttribute1 abc

    You can also try to run the below cmdlet:

    Get-Maillbox "user" | Set-Mailbox -CustomAttribute1 abc

     Please remember to mark the replies as answers if they help and unmark them if they provide no help. If you have feedback for TechNet Subscriber Support, contact tnmff@microsoft.com.

    Frank Wang

    TechNet Community Support

    Friday, March 02, 2012 9:19 AM
  •  

    Hi.
    We created a lot of test users with spaces in almost every attribute and we’re not able to reproduce the problem, and you neither.
    However, even when our client manually executes the set-mailbox command (outside the script), he gets the error.
    We need more investigation on their site, in their AD. We have no clue about what the root cause might be. I’ll keep you informed.

    Regards,
    Peter

    This is the outcome of the command from our client:

    PS C:\Users\peter> Set-mailbox –identity peter.vankeymeulen@test.be -EmailAddressPolicyEnabled:$false -UseDatabaseQuotaDefaults:$false -IssueWarningQuota 419841 -ProhibitSendQuota 483393536 -ProhibitSendReceiveQuota 5368709012Set-Mailbox : Property expression "Keymeulen Van" isn't valid. Valid values are: Strings formed with characters from A to Z(uppercase or lowercase), digits from 0 to 9, !, #, $, %, &, ', *, +, -, /, =, ?, ^, _, `, {, |, } or ~. One or more periods may be embedded in an alias, but each period should be preceded and followed by at least one of the other characters. Unicode characters from U+00A1 to U+00FF are also valid in an alias, but they will be mapped to a best-fit US-ASCII string in the e-mail address, which is generated from such an alias. Property Name: AliasAt line:1 char:12+ Set-mailbox <<<<  -identity peter.vankeymeulen@test.be -EmailAddressPolicyEnabled:$false -UseDatabaseQuotaDefaults:$false -IssueWarningQuota 419841 -ProhibitSendQuota 483393536 -ProhibitSendReceiveQuota 5368709012    + CategoryInfo          : NotSpecified: (test.be... peter.vankeymeulen:ADObjectId) [Set-Mailbox], DataValidati   onException    + FullyQualifiedErrorId : 2C4BA318,Microsoft.Exchange.Management.RecipientTasks.SetMailbox

    PS C:\Users\peter>


    Peter Van Keymeulen, IT Infrastructure Solution Architect, www.edeconsulting.be

    Friday, March 02, 2012 2:15 PM
  • Hi Peter - can you validate that their environment and yours are on the same build of Exchange (SP & RU) and also the domain controller too.

    Looking to eliminate variables!


    Cheers, Rhoderick

    Friday, March 02, 2012 3:36 PM
  • Hi Peter,

    Could you please also run Get-Mailbox "testmailbox" | fl and post the result here?


    Frank Wang

    TechNet Community Support

    Monday, March 05, 2012 3:09 AM