none
PowerShell - Pipeline not executed because a pipeline is already executing. Pipelines cannot be executed concurrently. RRS feed

  • Question

  • I understand that this question has been asked before on a few forums, however, please hear me out... 
    @mods please note that I posted this question in the wrong area so I'm re-posting it here.

    What I was trying to accomplish was to remove a user from any distribution groups that he/she is a member of. Within my organization we have several DGs and removing one user from all distribution groups is just one to many clicks for my taste. After searching online I found that this question has been answered and multiple admins have responded that they have been able to user the posted script below. However, when I attempt to run the script from within my organization I get the following error: "
    Pipeline not executed because a pipeline is already executing. Pipelines cannot be executed concurrently." Anyone have any idea as to why others can run scripts with multiple pipelines in their exchange environment, yet I'm unable to within my organization?

    $email = Read-Host 'Remove Distribution Group membership for which email?'
    
    $DGs= Get-DistributionGroup | where { ((Get-DistributionGroupMember $_ )| foreach {$_.PrimarySmtpAddress}) -contains $email}
     
    foreach( $dg in $DGs){
    	Remove-DistributionGroupMember $dg -Member $email
    }


    UPDATE: 
    Ok, so I've figured out how to get this running without pipes (See script below for version without pipes). Hope this helps anyone having the same issue. Does anyone have any suggestions as to how I can improve the script below? Much appreciated!

    $email = Read-Host 'Remove Distribution Group membership for which email?'
    
    $DGs= Get-DistributionGroup #| where { ((Get-DistributionGroupMember $_ )| foreach {$_.PrimarySmtpAddress}) -contains $email}
     
    foreach( $dg in $DGs){
        $Membs = Get-DistributionGroupMember $dg.PrimarySmtpAddress
        
        foreach ($mem in $Membs) {
            if ($mem.PrimarySmtpAddress -eq $email){
               
        	   Remove-DistributionGroupMember $dg.Name -Member $mem.Name
            }
        }
    }


    Friday, May 3, 2013 10:58 PM

All replies

  • On Fri, 3 May 2013 22:58:10 +0000, Coders.Defense.Coalition wrote:
     
    >
    >
    >I understand that this question has been asked before on a few forums, however, please hear me out... @mods please note that I posted this question in the wrong area so I'm re-posting it here. What I was trying to accomplish was to remove a user from any distribution groups that he/she is a member of. Within my organization we have several DGs and removing one user from all distribution groups is just one to many clicks for my taste. After searching online I found that this question has been answered and multiple admins have responded that they have been able to user the posted script below. However, when I attempt to run the script from within my organization I get the following error: "Pipeline not executed because a pipeline is already executing. Pipelines cannot be executed concurrently." Anyone have any idea as to why others can run scripts with multiple pipelines in their exchange environment, yet I'm unable to within my organization? $email = Read-Host 'Remove Distribution
    >Group membership for which email?'
     
    Duplicate. Answered in another forum.
     
    ---
    Rich Matheisen
    MCSE+I, Exchange MVP
     

    --- Rich Matheisen MCSE+I, Exchange MVP
    Sunday, May 5, 2013 2:50 AM