gpt4 book ai didi

sharepoint - 使用PowerShell取消多个SharePoint工作流

转载 作者:行者123 更新时间:2023-12-04 13:20:44 24 4
gpt4 key购买 nike

如何取消SharePoint(2010)列表中所有正在运行的工作流?

我通过technet找到了该脚本。

http://social.technet.microsoft.com/Forums/en-US/sharepoint2010programming/thread/d3913265-9712-4e61-9e38-1f9b78c8f718/

代码:

using (SPSite oSite = new SPSite("<your url>"))
{
foreach (SPWeb oWeb in oSite.AllWebs)
{
oWeb.AllowUnsafeUpdates = true;

// stop list workflows
foreach (SPList list in oWeb.Lists)
{
foreach (SPListItem oItem in list.Items)
{
foreach (SPWorkflow workflow in oItem.Workflows)
{
SPWorkflowManager.CancelWorkflow(workflow);
}
}
}

// stop site workflows
foreach (SPWorkflow workflow in oWeb.Workflows)
{
SPWorkflowManager.CancelWorkflow(workflow);
}

oWeb.AllowUnsafeUpdates = false;
oWeb.Dispose();
}
}

非常感谢您的帮助。

最佳答案

试一试。

我对其进行了修改,以使其在特定网站上的特定列表上完成。

#Site URL
$web = Get-SPWeb "http://urlforsite.com";
$web.AllowUnsafeUpdates = $true;

#List Name
$list = $web.Lists["ListName"];

# Iterate through all Items in List and all Workflows on Items.
foreach ($item in $list.Items) {
foreach ($wf in $item.Workflows) {

#Cancel Workflows
[Microsoft.SharePoint.Workflow.SPWorkflowManager]::CancelWorkflow($wf);
}
}
$web.Dispose();

对我来说工作得很好。请让我知道这对你有没有用。

关于sharepoint - 使用PowerShell取消多个SharePoint工作流,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7595256/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com