Needed to audit a farm to see if a CodePlex solution was being used in SharePoint Designer workflows. In my case, I needed to see where the iLove SharePoint solution was being used. The script below is only targeted at one web and is looking for word “ILoveSharePoint” in the XML.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 | if ((Get-PSSnapin "Microsoft.SharePoint.PowerShell" -ErrorAction SilentlyContinue) -eq $null) { Add-PSSnapin "Microsoft.SharePoint.PowerShell" } [Microsoft.SharePoint.SPSecurity]::RunWithElevatedPrivileges( { $resultsarray =@() #output file name $fileName = "C:\ilsp-" + $(Get-Date -Format "yyyyMMddHHmmss") + ".csv" #name of the feature we are looking for $wFeatureName = "ILoveSharePoint" Function GetFiles($folder) { foreach($file in $folder.Files) { if($file.Name.Split('.')[-1] -eq "xoml") { $web2 = Get-SPWeb $file.Web.Url $wFile = $web2.GetFileOrFolderObject($web2.URL +"/"+ $file.URL) if ($wFile.Exists -eq "True") { [xml]$wXml = (New-Object System.Text.UTF8Encoding).GetString($wFile.OpenBinary()); $nsDetail = $wXml.OuterXml.ToLower() $wFeatureName = $wFeatureName.ToLower() if($nsDetail -Like "*$wFeatureName*") { $outFolder = $folder -replace "Workflows/","" $outObject = new-object PSObject $outObject | add-member -membertype NoteProperty -name "URL" -Value $web2.Url $outObject | add-member -membertype NoteProperty -name "Workflow" -Value $outFolder $outObject | add-member -membertype NoteProperty -name "Created By" -Value $wFile.Author $outObject | add-member -membertype NoteProperty -name "Created Date" -Value $wFile.TimeCreated $outObject | add-member -membertype NoteProperty -name "Modified By" -Value $wFile.ModifiedBy $outObject | add-member -membertype NoteProperty -name "Modified Date" -Value $wFile.TimeLastModified $global:resultsarray += $outObject } } } } # Use recursion to loop through all subfolders. foreach ($subFolder in $folder.SubFolders) { GetFiles($Subfolder) } } $WebApplications = Get-SPWebApplication foreach($webApp in $WebApplications) { foreach($site in $webApp.Sites) { if ((Get-SPSite $site.url -ErrorAction SilentlyContinue) -ne $null) { foreach($web in $site.AllWebs) { if ((Get-SPWeb $web.url -ErrorAction SilentlyContinue) -ne $null) { $list1 = $web.Lists.TryGetList("Workflows") if($list1 -ne $null) { GetFiles($list1.RootFolder) } } } } } } #output file $resultsarray | Export-csv $fileName -notypeinformation } ) |