Finding FormsLib, List Based InfoPaths and custom WFs in a Farm


Below script generates an excel file indicating the forms library, list based forms and custom workflows, including SPD and visual studio ones inside a webapp. Script is valid for Moss 2007/SharePoint 2010 and SharePoint 2013 versions.

[Void][System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint")
[Void][System.Reflection.Assembly]::LoadWithPartialName("System.Web")

$table = New-Object System.Data.DataTable

$col1 = New-Object system.Data.DataColumn "weburl",([string])
$col2 = New-Object system.Data.DataColumn "Listurl",([string])
$col3 = New-Object system.Data.DataColumn "IsFromsLib",([string])
$col4 = New-Object system.Data.DataColumn "IsListBasedIP",([string])
$col5 = New-Object system.Data.DataColumn "CustomWFName",([string])

$table.Columns.Add($col1)
$table.Columns.Add($col2)
$table.Columns.Add($col3)
$table.Columns.Add($col4)
$table.Columns.Add($col5)

$row = $table.NewRow()

$webApplication = [Microsoft.SharePoint.Administration.SPWebApplication]::Lookup("<webappurl>")

foreach($site in $webApplication.Sites)
{
foreach($web in $site.allwebs)
{
foreach($list in $web.lists)
{
$flag = $false

if($list.BaseTemplate -eq "XMLForm")
{
write-host "Forms Lib :" $web.url, $list.title
$row.weburl = $web.url
$row.Listurl = $list.title
$row.IsFromsLib = $true
$formslibcount++
$flag = $true
}
if($list.ContentTypes[0].ResourceFolder.Properties[“_ipfs_infopathenabled”] -eq $true)
{
write-host "List based Form :" $web.url, $list.title
$row.weburl = $web.url
$row.Listurl = $list.title
$row.IsListBasedIP = $true
$iplibs++
$flag = $true
}
if($list.workflowassociations.count -ne 0)
{
foreach($wfass in $list.workflowassociations)
{
if(($wfass.ModificationUrl -eq $null) -and ($wfass.enabled -eq $true))
{
write-host $web.url, $list.title, $wfass.internalname, $wfass.enabled
$row.weburl = $web.url
$row.Listurl = $list.title
$row.CustomWFName = $wfass.internalname
$count++
$table.Rows.Add($row)
$row = $table.NewRow()
$flag = $true
}
}
}
if($flag)
{
$table.Rows.add($row)
$row = $table.NewRow()
}
}
}
}

$grid = new-object System.Web.UI.WebControls.DataGrid

$grid.DataSource = $table

$grid.DataBind()
$fileinfo = "<path to xls file>"

$streamwriter = new-object System.IO.StreamWriter $fileinfo

$htmltextwriter = new-object System.Web.UI.HtmlTextWriter $streamwriter

$grid.RenderControl($htmltextwriter)

$htmltextwriter.close()

$streamwriter.Close()

Comments (0)

Skip to main content