none
Can someone look at this script and tell me why I .... RRS feed

  • Question

  •    am getting the error 

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

    about 20 times?

     

    Here is the script I am trying to use to remove a member with the smtp address "tempmbx@domain.ca" from all Distribution Groups:

    $DGs= Get-DistributionGroup | where { (Get-DistributionGroupMember $_ | foreach {$_.PrimarySmtpAddress}) -contains "tempmbx@domain.ca"}

    foreach( $dg in $DGs){
    Remove-DistributionGroupMember $dg -Member tempmbx@domain.ca
    }

    Please help.

    Drock

    Wednesday, March 1, 2017 9:27 PM

Answers

  • Get-DistributionGroup | 
    	ForEach-Object{
    		Remove-DistributionGroupMember $_.Alias -member tempmbx@domain.ca -WhatIf
    	}

    For just removing a single member from all groups:

    Get-DistributionGroup | Remove-DistributionGroupMember -member tempmbx@domain.ca -WhatIf


    \_(ツ)_/




    • Edited by jrv Wednesday, March 1, 2017 9:50 PM
    • Marked as answer by drock13 Thursday, March 2, 2017 9:32 PM
    Wednesday, March 1, 2017 9:47 PM

All replies

  • Exchange CmdLets do not allow pipelining in this way.  It is due to the remoting mechanism that they are using.  Up will need to do this in discrete steps.


    \_(ツ)_/

    Wednesday, March 1, 2017 9:37 PM
  • Get-DistributionGroup | 
    	ForEach-Object{
    		Remove-DistributionGroupMember $_.Alias -member tempmbx@domain.ca -WhatIf
    	}

    For just removing a single member from all groups:

    Get-DistributionGroup | Remove-DistributionGroupMember -member tempmbx@domain.ca -WhatIf


    \_(ツ)_/




    • Edited by jrv Wednesday, March 1, 2017 9:50 PM
    • Marked as answer by drock13 Thursday, March 2, 2017 9:32 PM
    Wednesday, March 1, 2017 9:47 PM