Welcome › Forums › General PowerShell Q&A › The pipeline has been stopped in parallel execution
- This topic has 1 reply, 2 voices, and was last updated 4 months, 1 week ago by
Participant.
-
AuthorPosts
-
-
August 21, 2020 at 3:10 am #251507
Hello.
I have pipeline break when trying proceed hashtable keys to foreach-object in parallel. So it happens almost always, but some object gonna pass normally. I have no idea which object cause this problem, because it break before start execution. Keys dont have null object (i check it double)
code
PowerShell1234567891011121314151617$scriptThrottleLimit = 6$scriptTimeoutLimit = 60$groupsArrays = Get-ADGroup -SearchBase "OU=Groups,DC=domain,DC=local" -Filter {samaccountname -like "Department-*"} | Select-Object SamAccountName$usersArray = @()foreach ($group in $groupsArrays.samaccountname) {$usersArray += Get-ADGroupMember $group -Recursive | Select-Object samaccountname}foreach ($usr in $usersArray.SamAccountName){if (!($userGrpArray.ContainsKey($usr))) {$grp = Get-ADPrincipalGroupMembership -Identity $usr | Where-Object {$_.DistinguishedName -like 'CN=CID-*'} | Select-Object SamAccountName$userGrpArray.Add($usr,$grp)}}$userGrpArray.Keys | ForEach-Object -Parallel {Write-Output $_} -ThrottleLimit $scriptThrottleLimit -TimeoutSeconds $scriptTimeoutLimiterror
PowerShell12345InvalidOperation: C:\Users\user\Desktop\activedirectory\Change-CIDUsers.ps1:75:1Line |75 | $userGrpArray.Keys | ForEach-Object -Parallel {| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~| The pipeline has been stopped.full error stack
PowerShell1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950Type : System.Management.Automation.ActionPreferenceStopExceptionErrorRecord :Exception :Type : System.Management.Automation.PipelineStoppedExceptionErrorRecord :Exception :Type : System.Management.Automation.ParentContainsErrorRecordExceptionMessage : The pipeline has been stopped.HResult : -2146233087CategoryInfo : OperationStopped: (:) [], ParentContainsErrorRecordExceptionFullyQualifiedErrorId : PipelineStoppedTargetSite :Name : ThrowDeclaringType : System.Runtime.ExceptionServices.ExceptionDispatchInfoMemberType : MethodModule : System.Private.CoreLib.dllStackTrace :at System.Management.Automation.Internal.PipelineProcessor.SynchronousExecuteEnumerate(Object input)at System.Management.Automation.Runspaces.LocalPipeline.InvokeHelper()at System.Management.Automation.Runspaces.LocalPipeline.InvokeThreadProc()Message : The pipeline has been stopped.Source : System.Private.CoreLibHResult : -2146233087TargetObject : System.Management.Automation.PSTasks.PSTaskCategoryInfo : InvalidOperation: (System.Management.A…tion.PSTasks.PSTask:PSTask) [], PipelineStoppedExceptionFullyQualifiedErrorId : PSTaskExceptionInvocationInfo :ScriptLineNumber : 75OffsetInLine : 1HistoryId : -1ScriptName : C:\Users\user\Desktop\activedirectory\Change-CIDUsers.ps1Line : $userGrpArray.Keys | ForEach-Object -Parallel {PositionMessage : At C:\Users\user\Desktop\activedirectory\Change-CIDUsers.ps1:75 char:1+ $userGrpArray.Keys | ForEach-Object -Parallel {+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~PSScriptRoot : C:\Users\user\Desktop\activedirectory\PSCommandPath : C:\Users\user\Desktop\activedirectory\Change-CIDUsers.ps1CommandOrigin : InternalScriptStackTrace : at <ScriptBlock>, C:\Users\user\Desktop\activedirectory\Change-CIDUsers.ps1: line 75TargetSite :Name : InvokeDeclaringType : System.Management.Automation.Runspaces.PipelineBase, System.Management.Automation, Version=7.0.3.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35MemberType : MethodModule : System.Management.Automation.dllStackTrace :at System.Management.Automation.Runspaces.PipelineBase.Invoke(IEnumerable input)at System.Management.Automation.PowerShell.Worker.ConstructPipelineAndDoWork(Runspace rs, Boolean performSyncInvoke)at System.Management.Automation.PowerShell.Worker.CreateRunspaceIfNeededAndDoWork(Runspace rsToUse, Boolean isSync)at System.Management.Automation.PowerShell.CoreInvokeHelper[TInput,TOutput](PSDataCollection[crayon-601142274caa6328096322 inline="true" ]1 input, PSDataCollection1.<ExecuteCommandAsync>b__0() in D:\a\1\s\src\PowerShellEditorServices\Services\PowerShellContext\PowerShellContextService.cs:line 778 at System.Threading.Tasks.Task
1.InnerInvoke() at System.Threading.ExecutionContext.RunFromThreadPoolDispatchLoop(Thread threadPoolThread, ExecutionContext executionContext, ContextCallback callback, Object state) --- End of stack trace from previous location where exception was thrown --- at System.Threading.Tasks.Task.ExecuteWithThreadLocal(Task& currentTaskSlot, Thread threadPoolThread) --- End of stack trace from previous location where exception was thrown --- at Microsoft.PowerShell.EditorServices.Services.PowerShellContextService.ExecuteCommandAsync[TResult](PSCommand psCommand, StringBuilder errorMessages, ExecutionOptions executionOptions) in D:\a\1\s\src\PowerShellEditorServices\Services\PowerShellContext\PowerShellContextService.cs:line 778 at Microsoft.PowerShell.EditorServices.Services.PowerShellContextService.ExecuteCommandAsync[TResult](PSCommand psCommand, StringBuilder errorMessages, ExecutionOptions executionOptions) in D:\a\1\s\src\PowerShellEditorServices\Services\PowerShellContext\PowerShellContextService.cs:line 823 Message : The running command stopped because the preference variable "ErrorActionPreference" or common parameter is set to Stop: The pipeline has been stopped. Data : System.Collections.ListDictionaryInternal Source : System.Management.Automation HResult : -2146233087[/crayon]enviroment
PowerShell1234PSVersion 7.0.3PSEdition CoreGitCommitId 7.0.3OS Microsoft Windows 10.0.14393-
This topic was modified 5 months, 1 week ago by
franky.why.
-
This topic was modified 5 months, 1 week ago by
grokkit.
-
This topic was modified 5 months, 1 week ago by
-
September 19, 2020 at 8:36 am #257540
The error record contains: ‘The running command stopped because the preference variable “ErrorActionPreference” or common parameter is set to Stop’.
So there must be some problem in the data that is causing an exception. Try changing $ErrorActionPreference to ‘Continue’. You may get more information. At least you may see where the data is missing or broken.
-
-
AuthorPosts
- The topic ‘The pipeline has been stopped in parallel execution’ is closed to new replies.