PowerShell to find Available workflows in site collection

$site = Get-SPSite("http://yoursiteurl/sites/ss");
$site.AllWebs | foreach { $_.Lists | foreach { $_.WorkflowAssociations | foreach {
write-host "Site URL :" $_.ParentWeb.Url ", List Name :" $_.ParentList.Title ", Workflow Name :" $_.Name
} } }

$siteurl="http://yoursiteurl/sites/ss"
$site=Get-SPSite("http://yoursiteurl/sites/ss");
#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 E:\workflows.csv
"Workflow Count " + $workflowcount >> E:\workflows.csv
$site.Dispose()

Comments

Popular posts from this blog

How to Improve Workflow Performance in SharePoint Server 2010

PowerShell Script to Check and Generate Report on Access Rights for a Specific User:

Disable Loopbackcheck using PowerShell