Introduction
How does the script works
- The script is run by providing the Url for the Web Application
- The script will enumerate through all the site collections in the web application and creates an array object which has two properties, SiteCollection and Solution
- Once all site collections have been enumerated then the array will be outputted.
param ( [Parameter(Mandatory=$false, HelpMessage='Solution Name')] [string]$SolutionName="", [Parameter(Mandatory=$false, HelpMessage='Solution Name')] [string]$WebApplicationUrl="")$memoryAssignment = Start-SPAssignment; $numberOfSolutionsFound = 0; $webApplication = Get-SPWebApplication -Identity $WebApplicationUrl -ErrorAction SilentlyContinue -AssignmentCollection $memoryAssignment; if($webApplication -ne $null) { #enumerate through site collections in web application $allSites = Get-SPSite -WebApplication $webApplication -Limit ALL -Confirm:$false -AssignmentCollection $memoryAssignment; foreach($checkSite in $allSites) { #Write-Output "Checking Site " $checkSite.Url " for solution " $SolutionName; if($SolutionName -eq "") { $checkSolutions = Get-SPUserSolution -Site $checkSite -AssignmentCollection $memoryAssignment; foreach($solution in $checkSolutions) { $output = New-Object -TypeName "System.Object"; Add-Member -InputObject $output -MemberType NoteProperty -Name "Solution" -Value ""; Add-Member -InputObject $output -MemberType NoteProperty -Name "SiteCollection" -Value ""; $output.Solution = $solution; $output.SiteCollection = $checkSite; Write-Output -InputObject $output; $numberOfSolutionsFound++ } } else { $checkSolution = Get-SPUserSolution -Identity $SolutionName -Site $checkSite -ErrorAction SilentlyContinue -AssignmentCollection $memoryAssignment; if($checkSolution -ne $null) { $output = New-Object -TypeName "System.Object"; Add-Member -InputObject $output -MemberType NoteProperty -Name "Solution" -Value ""; Add-Member -InputObject $output -MemberType NoteProperty -Name "SiteCollection" -Value ""; $output.Solution = $checkSolution; $output.SiteCollection = $checkSite; Write-Output -InputObject $output; $numberOfSolutionsFound++ } } } }</p> <p style="direction: ltr; margin-top: 0; margin-left: 0; width: 7.5875in;">Write-Output "Found $numberOfSolutionsFound Instances of Solution $SolutionName"; Stop-SPAssignment $memoryAssignment;</p> <p style="direction: ltr; margin-top: 0; margin-left: 0; width: 7.5875in;">
How to execute the script
- Logon to SharePoint 2013 server
- Run the SharePoint Management Shell
- .\Get-SPUserSolutionInWebApplication -WebApplicationUrl https://sharepoint
- There is an optional parameter -SolutionName which allows you to only return the solutions with a particular name
The script will output an array of Solution Objects with an associated Site Collection object.
We can assign a value to the output and then do some further processing using that value.
Here is an example of the output from the script without assigning the result to a variable.
To do something more useful then assign the output to a variable. You can then enumerate through the variable array.
For example, the following screenshot shows the output being assigned to a variable $solutions and then it is being enumerated using the following:
$solutions | %{Write-Host $_.Solution.Name “in” $_.SiteCollection.Url}
Downloads
If you would like to try out the PowerShell script, then you can download the script here:
Get-SPUserSolutionInWebApplication.zip
Please fill free to use and modify the script, though make sure you test it before using in Production.
Also let me know if you find it useful and if you have made some cool changes let me know as always looking for ways to make things better!