您好,有什么方法可以将所有 2013 年工作流程检索到 SharePoint 网站吗?我们的服务器存在此问题,WorkFlow Manager 2013 使用我们所有的服务器资源,导致 CPU 使用率达到 100%,我们需要知道用户创建的工作流程是什么导致了此问题。
到目前为止,我有以下代码可以将所有 WF 2010 检索到我们的以下网站:
Add-PSSnapin Microsoft.SharePoint.PowerShell -ea 0
$site=Get-SPSite("mysite dot com");
#Initialize Workflow Count variable
$workflowcount = 0
#Foreach loop to loop through all webs, and lists with workflow associations, and exclude workflows that have previous versions and write findings to .csv file.
function Get-Workflows()
{
foreach($web in $site.AllWebs)
{
foreach($list in $web.Lists)
{
foreach($wf in $list.WorkflowAssociations)
{
if ($wf.Name -notlike "*Previous Version*")
{
$hash = @{"[URL]"=$web.Url;"[List Name]"=$list.Title;"[Workflow]"=$wf.Name}
New-Object PSObject -Property $hash | Sort-Object
}
}
}
}
}
foreach($web in $site.AllWebs)
{
foreach($list in $web.Lists)
{
foreach($wf in $list.WorkflowAssociations)
{
if ($wf.Name -notlike "*Previous Version*")
{
$workflowcount += 1
}
}
}
}
Get-Workflows | Export-csv C:\Users\Documents\rey.csv
"Workflow Count " + $workflowcount >> C:\Users\Documents\rey.csv
$site.Dispose()
感谢任何帮助。
谢谢!
最佳答案
您可以尝试此操作以获取网站中的所有 2013 年工作流程。
$web = Get-SPWeb -identity $url
$wfm = New-object Microsoft.SharePoint.WorkflowServices.WorkflowServicesManager($web)
$defSevice = $wfm.GetWorkflowDeploymentService()
$wfDefs = $defSevice.EnumerateDefinitions($false)
foreach ($wfDef in $wfDefs){
$wfDef.properties
}
$wfDef.properties 将列出与工作流程相关的所有属性。就像 RestrictToScope 一样,它为您提供关联列表的 GUID。
关于c# - 如何使用 powershell/c# 列出 SharePoint 中的所有 2013 工作流程,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39951496/