[英]How to list all 2013 workflows in SharePoint using powershell/c#
Hi is there any way to retrieve all 2013 workflows to SharePoint Site?嗨,有什么方法可以将所有 2013 工作流检索到 SharePoint 站点? We have this problem regarding our server where WorkFlow Manager 2013 uses all our server resources causing 100% CPU Usage and we need to know what are the workflows created by our users causing this.我们的服务器存在此问题,其中 WorkFlow Manager 2013 使用我们所有的服务器资源导致 100% CPU 使用率,我们需要知道导致此问题的用户创建的工作流是什么。
As of now I have below code to retrieve all WF 2010 to our sites below:截至目前,我有以下代码可将所有 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()
Any help is appreciated.任何帮助表示赞赏。
Thanks!谢谢!
You can try this to get all 2013 workflows in a site.您可以尝试此操作以获取站点中的所有 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 will list you all properties concerning the workflow. $wfDef.properties 将列出有关工作流的所有属性。 Like RestrictToScope which give you the GUID of associated list.像 RestrictToScope 一样,它为您提供关联列表的 GUID。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.