powershell PS SP搜索工作流程组件

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了powershell PS SP搜索工作流程组件相关的知识,希望对你有一定的参考价值。

$webApplicationName = "https://homepoxxxxx"
$path = "F:\temp\SPDActionsSearch.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*")
					{
						$xml = [xml]$wa.BaseTemplate.xml
						$node = $xml.WorkflowTemplate.Metadata.Instantiation_FormURI.string
						$xsnPath = $node
						if($xsnPath -ne $null)
						{
							#$itemFound = "xsnPath is null in workflow: $($wa.Name) on list: $($l.Title) in web $($web.Url)"
							#$itemFound | out-file $path -append
							$xsnPath = $xsnPath.Replace(" ","%20")
							$webRelativeFolder = $xsnPath.Substring(0, $xsnPath.LastIndexOf('/'))
							$xomlFileName = $xsnPath.Substring($xsnPath.LastIndexOf("/") + 1)
							$xomlFileName = $xomlFileName.Replace(".xsn",".xoml")
						}
						else
						{
							$xsnPath = $wa.InstantiationUrl.Replace(" ","%20")
							$webRelativeFolder = $xsnPath.Substring(0, $xsnPath.LastIndexOf('/'))
							$xomlFileName = $wa.Name + ".xoml"
						}
						$wfFolder = $wa.ParentWeb.GetFolder($webRelativeFolder)
						$xomlFile = $wfFolder.Files[$xomlFileName]
						$stream = $xomlFile.OpenBinaryStream()
						$xmlLoaded = New-Object System.Xml.XmlDocument
						$xmlLoaded.Load($stream)
						$fileContents = $xmlLoaded.OuterXml
						if($fileContents -like "*TransferListItem*")
						{
							$itemFound = "Found TransferListItem in workflow: $($wa.Name) on list: $($l.Title) in web $($web.Url)"
							$itemFound | out-file $path -append
							$found = $found + 1
						}
						if($fileContents -like "*MatchRegExp*")
						{
							$itemFound = "Found MatchRegExp in workflow: $($wa.Name) on list: $($l.Title) in web $($web.Url)"
							$itemFound | out-file $path -append
							$found = $found + 1
						}
						if($fileContents -like "*ReplaceRegExp*")
						{
							$itemFound = "Found ReplaceRegExp in workflow: $($wa.Name) on list: $($l.Title) in web $($web.Url)"
							$itemFound | out-file $path -append
							$found = $found + 1
						}
						if($fileContents -like "*StartAnotherWorkflow*")
						{
							$itemFound = "Found StartAnotherWorkflow in 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 = "Errir 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 PS SP用户配置文件权限

powershell PS SP比较字段

powershell PS SP用户配置文件获取用户

powershell SP PS用户配置文件AD权限

powershell PS SP将列表导出为CSV

powershell 如何定时执行 ps1