Changing email addresses to lowercase

This topic contains 0 replies, has 1 voice, and was last updated by Profile photo of Forums Archives Forums Archives 5 years, 3 months ago.

  • Author
    Posts
  • #6479

    by jiska78 at 2012-09-26 19:10:39

    I've updated by Email address policies as follows, which obviously converts email addresses to lowercase:
    %rAa%rBb%rCc%rDd%rEe%rFf%rGg%rHh%rIi%rJj%rKk%rLl%r Mm%rNn%rOo%rPp%rQq%rRr%rSs%rTt%rUu%rVv%rWw%rXx%rYy %rZz%1g%s@domain.com.au

    Changing that, however, won't alter existing email addresses as MS doesn't recognise case. Therefore I created the following PowerShell script to run through and change all the email addresses, but I'm getting the errors below. I must confess I'm not all that proficient at PowerShell, just learning at the moment, so any pointers would be appreciated.

    Get-Mailbox | foreach {

    for ($i = $_.EmailAddresses.Count ;$i -ge 0; $i — )
    {
    $_.EmailAddresses[$i].ProxyAddressString
    }
    set-mailbox $_.Identity -EmailAddressPolicyEnabled $false
    set-mailbox $_.Identity -EmailAddresses $_.EmailAdresses.ToLower()
    set-mailbox $_.Identity -EmailAddressPolicyEnabled $true
    }

    Pipeline not executed because a pipeline is already executing. Pipelines cannot be executed concurrently.
    + CategoryInfo : OperationStopped: (Microsoft.Power...tHelperRunspace:ExecutionCmdlet HelperRunspace) [],
    PSInvalidOperationException
    + FullyQualifiedErrorId : RemotePipelineExecutionFailed

    Pipeline not executed because a pipeline is already executing. Pipelines cannot be executed concurrently.
    + CategoryInfo : OperationStopped: (Microsoft.Power...tHelperRunspace:ExecutionCmdlet HelperRunspace) [],
    PSInvalidOperationException
    + FullyQualifiedErrorId : RemotePipelineExecutionFailed

    ForEach-Object : You cannot call a method on a null-valued expression.
    At C:\a.ps1:1 char:22
    + Get-Mailbox | foreach < <<< {
    + CategoryInfo : InvalidOperation: (ToLower:String) [ForEach-Object], RuntimeException
    + FullyQualifiedErrorId : InvokeMethodOnNull,Microsoft.PowerShell.Commands.F orEachObjectCommand

    by Helmto108 at 2012-09-30 13:58:55

    Hello,

    You can try wrapping () around Get-Mailbox, or assign the list of mailboxes to a variable and use that. Also, I believe that attribute that contains email addresses is ProxyAddresses, and not EmailAddresses.

    Regards,
    Helmto108

You must be logged in to reply to this topic.