Forum Discussion
Audi86
Aug 24, 2022Brass Contributor
Add a line to skip or continue loop execution
Hi I have a PS script which is terminating workflows in SharePoint. I don't want to run this script in one go rather I want to add user intervention as well. Below is my script portion. In line 44, I...
- Aug 25, 2022If you want to skip to the next loop iteration, without existing the loop/script, use the continue statement: https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_continue?view=powershell-7.2
VasilMichev
Aug 25, 2022MVP
If you want to skip to the next loop iteration, without existing the loop/script, use the continue statement: https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_continue?view=powershell-7.2
Audi86
Aug 25, 2022Brass Contributor
nevermind I got it with following code. Thanks alot all!
$Answer = Read-Host -Prompt "Do you want to Terminate this instance (y or n)?"
if ($Answer -eq "n")
{
Continue
}
$WorkflowInstanceService.TerminateWorkflow($WorkflowInstance)
$Ctx.ExecuteQuery()
Write-host -f Green "'$($WorkflowAssociations | where {$_.ID -eq $WorkflowInstance.WorkflowSubscriptionId} | Select -ExpandProperty Name)'is Terminated"