简体   繁体   English

如何使用 powershell/c# 列出 SharePoint 中的所有 2013 工作流

[英]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.

相关问题 sharepoint 2013 使用列表模板 C# 创建文档库 - sharepoint 2013 create document library using List Template C# 如何使用控制台应用程序[C#]检索成员的所有Sharepoint 2013 FBA用户? - How to retrieve all Sharepoint 2013 FBA user of a membership using console application [C#]? 如何在C#中使用SharePoint Online 2013 Rest API删除列表项 - How to delete list item using SharePoint Online 2013 Rest API in C# 如何使用C#在sharepoint 2013中更改组权限 - How to change group permissions in sharepoint 2013 using C# 使用c#登录到SharePoint 2013 - login to the SharePoint 2013 using c# 如何使用c#获取Sharepoint List - How to get Sharepoint List using c# 在SharePoint 2013工作流期间使用自定义类型的变量 - Using Custom Types for Variables during SharePoint 2013 Workflows 以编程方式将Listview添加到Sharepoint 2013 C#中的所有列表 - Add a listview programmatically to all lists in Sharepoint 2013 C# 如何使用C#以编程方式从SharePoint网站获取所有图片库的列表 - How to get list of all picture libraries from SharePoint site programatically using C# 如何在C#中使用sharepoint客户端模型获取所有内容类型组的列表 - how to get a list of all content type groups using sharepoint client model in c#
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM