Iterating through a SPWorkflow SPWorkflowTaskCollection?
-
2012년 5월 24일 목요일 오후 1:51
I am trying to iterate through a SPWorkflowTaskCollection but get the error below..
... Is there another technique?
Method invocation failed because [Microsoft.SharePoint.Workflow.SPWorkflo
wTaskCollection] doesn't contain a method named 'GetEnumerator'.
At C:\Users\nyannios\Documents\OLF-ModClientsWorkflows.ps1:813 char:39
+ $IEnum = $tasks.GetEnumerator <<<<
()
+ CategoryInfo : InvalidOperation: (GetEnumerator:String) [
], RuntimeException
+ FullyQualifiedErrorId : MethodNotFound
$tasks = [Microsoft.SharePoint.Workflow.SPWorkflowTaskCollection] $task = [Microsoft.SharePoint.Workflow.SPWorkflowTask] $IEnum = [System.Collections.IEnumerable] . . . $tasks = $_.Tasks $IEnum = $tasks.GetEnumerator() while ($IEnum.MoveNext()) { $task = $IEnum.Current write-Host "Task: " $task.DisplayName . . . }
Νικοσ Γιαννιοσ
- 편집됨 Nikos Yannios 2012년 5월 24일 목요일 오후 1:52 edit
모든 응답
-
2012년 5월 24일 목요일 오후 5:46
more detail: $ClientWebs | %{ $WebI = $_ Write-Host; "Web: " + $_.Title; $l = $_.Lists; $l | %{ $specificList = $_ $wfAssocArray = $_.WorkflowAssociations write-host "List: " $_.Title ; $_.WorkflowAssociations |%{ $wfassoc = $_ $wfid = $_.Id ' Workflow Association Name: {0} Internal: {1}' -f $_.Name, $_.InternalName $specificList.Items | %{ $spitem = $_ $_.Workflows | %{ $wfCount += 1 Write-Host -ForegroundColor Blue "WF: " $_.InstanceId $_.InternalState $_.IsCompleted $_.IsLocked if ($_.InternalState -match "Completed") {$wfCompleted += 1} if ($_.InternalState -match "Running") {$wfRunning += 1} $tasks = $_.Tasks $IEnum = $tasks.GetEnumerator() while ($IEnum.MoveNext()) { $task = $IEnum.Current write-Host -ForegroundColor DarkMagenta "Task: " $task.DisplayName } } } } } }Νικοσ Γιαννιοσ
-
2012년 5월 29일 화요일 오후 7:20
$ClientWebs | %{ $WebI = $_ Write-Host; "Web: " + $_.Title; $l = $_.Lists; $l | %{ $specificList = $_ $wfAssocArray = $_.WorkflowAssociations write-host "List: " $_.Title ; $_.WorkflowAssociations |%{ $wfassoc = $_ $wfid = $_.Id ' Workflow Association Name: {0} Internal: {1}' -f $_.Name, $_.InternalName $specificList.Items | %{ $spitem = $_ $_.Workflows | %{ $wfCount += 1 Write-Host -ForegroundColor Blue "WF: " $_.InstanceId $_.InternalState $_.IsCompleted $_.IsLocked if ($_.InternalState -match "Completed") {$wfCompleted += 1} if ($_.InternalState -match "Running") {$wfRunning += 1} $tasks = $_.Tasks foreach ($task in $tasks) { write-Host -ForegroundColor DarkMagenta "Task: " $task.DisplayName . . . } } } } } }changed from using GetEnumerator() to simply using foreach() to iterate through the tasks. That worked. Now i can edit through all the associated tasks with a workflow instance and find their associated Task Lists, etc.
Νικοσ Γιαννιοσ
- 편집됨 Nikos Yannios 2012년 5월 29일 화요일 오후 7:22 more typos
- 답변으로 표시됨 Nikos Yannios 2012년 5월 29일 화요일 오후 7:22

