bulk remove exchange alias

I had this question after viewing Exchange 2010 remove .local smtp addresses.

I modified this script to remove a test domain we have and I keep getting the following error

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

My script looks like this
Get-Mailbox | %{
    $EmailAddress = $_.EmailAddresses | ?{$_ -notlike "*mxtest*"}
    $_ | Set-Mailbox -EmailAddresses $EmailAddress
    }

When I tried this for a single user to test, it worked like a charm.  Only when I removed the username did it error.

The domain we want to get rid of is mxtest.domain.com.
Running exchange 2010 SP3
Thoughts and thanks in advance.
mgitAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

MaheshArchitectCommented:
try below

Get-Mailbox | %{
     $EmailAddress = $_.EmailAddresses | ?{$_ -notlike "*mxtest*"} | Set-Mailbox -EmailAddresses $EmailAddress
     }

Open in new window

I have removed extra pipeline
0
mgitAuthor Commented:
I'm afraid that didn't work.

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

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

Invoke-Command : Cannot write input as there are no more running pipelines
At C:\Users\robertferguson\AppData\Roaming\Microsoft\Exchange\RemotePowerShell\server1.domain.com\server1.domain.com.psm1:50548 char:29
+             $scriptCmd = { & <<<<  $script:InvokeCommand `
    + CategoryInfo          : InvalidOperation: (:) [Invoke-Command], PSInvalidOperationException
    + FullyQualifiedErrorId : NoMoreInputWrite,Microsoft.PowerShell.Commands.InvokeCommandCommand

Thanks for replying so quickly..
0
Todd NelsonSystems EngineerCommented:
I use this script to remove old proxy addresses from mailboxes--provided the addresses are not being applied with an Exchange email address policy.

$Mailboxes = Get-Mailbox -ResultSize Unlimited

$Mailboxes | foreach {
   for ($i=0;$i -lt $_.EmailAddresses.Count; $i++)
   {
      $address = $_.EmailAddresses[$i]
      if ($address.IsPrimaryAddress -eq $false -and $address.SmtpAddress -like "*DOMAIN-TO-REMOVE.com" )
      {

         Write-host($address.AddressString.ToString() | out-file C:\MailboxAddressesRemoved.txt -append )
         $_.EmailAddresses.RemoveAt($i)
         $i--
      }
   }
   Set-Mailbox -Identity $_.Identity -EmailAddresses $_.EmailAddresses
}

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Aaron GuilmetteTechnology Solutions ProfessionalCommented:
0
mgitAuthor Commented:
Thank you
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Exchange

From novice to tech pro — start learning today.