powershell PS SP列出所有工作流程
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了powershell PS SP列出所有工作流程相关的知识,希望对你有一定的参考价值。
$webApplicationName = "https://homeportnw.psns.navy.mil"
$path = "F:\temp\AllWorkflows.log"
If (Test-Path $path){
Remove-Item $path
}
$found = 0
$wa = Get-SPWebApplication $webApplicationName
foreach($site in $wa.Sites)
{
$siteUrl = $site.Url
write-host "Site $siteUrl" -backgroundcolor darkred -foregroundcolor white
$allWebs = $site.AllWebs
foreach ($web in $allWebs)
{
write-host "Searching Web: $($web.Url)" -backgroundcolor blue
$lists = $web.Lists
foreach($l in $lists)
{
write-host "Searching list: $($l.Title)" -backgroundcolor green -foregroundcolor black
foreach ($wa in $l.WorkflowAssociations)
{
try
{
if($wa.Name -notlike "*Previous*")# previous workflows are still listed in the association
{
$xml = [xml]$wa.BaseTemplate.xml
$node = $xml.WorkflowTemplate.Metadata.Instantiation_FormURI.string
$xsnPath = $node
if($xsnPath -ne $null)
{
$xsnPath = $xsnPath.Replace(" ","%20")
$webRelativeFolder = $xsnPath.Substring(0, $xsnPath.LastIndexOf('/'))
}
else #do this for old workflows tha do not instantiation forms
{
if($wa.InstantiationUrl -ne $null) #OOBs do not have an InstantiationUrl
{
$xsnPath = $wa.InstantiationUrl.Replace(" ","%20")
$webRelativeFolder = $xsnPath.Substring(0, $xsnPath.LastIndexOf('/'))
}
}
try #if the folder does not exists catch the error and it will be an OOB workflow
{
$wfFolder = $wa.ParentWeb.GetFolder($webRelativeFolder)
$itemFound = "Custom Workflow: $($wa.Name) on list: $($l.Title) in web $($web.Url)"
$itemFound | out-file $path -append
$found = $found + 1
}
catch
{
$itemFound = "OOB Workflow: $($wa.Name) on list: $($l.Title) in web $($web.Url)"
$itemFound | out-file $path -append
$found = $found + 1
}
}#end if $wa.Name -notlike "*Previous*"
}#end try
catch
{
"--------------------------------------------------------------------" | out-file $path -append
write-error $_
$_ | out-file $path -append
$itemFound = "Error in search in workflow: $($wa.Name) on list: $($l.Title) in web $($web.Url)"
$itemFound | out-file $path -append
"--------------------------------------------------------------------" | out-file $path -append
}#end catch
}# end for each workflow association
}
}
}
write-host "Total items found: $found"
以上是关于powershell PS SP列出所有工作流程的主要内容,如果未能解决你的问题,请参考以下文章
如何用PowerShell列出你机器上的.NET Framework的版本号和SP服务补丁
powershell PS SP用户配置文件权限
powershell PS SP比较字段
powershell PS SP用户配置文件获取用户
powershell SP PS用户配置文件AD权限
powershell PS SP将列表导出为CSV