Here is a sample script for your reference:
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++
}
}
}
}
Write-Output "Found $numberOfSolutionsFound Instances of Solution $SolutionName"
Stop-SPAssignment $memoryAssignment
You can save the script as a PS1 file and then execute the script using
PS C:\PS1FileLocation> .\Get-SPUserSolutionInWebApplication -WebApplicationUrl <WebAppURL>
Reference: PowerShell: Getting Sandbox Solutions in a SharePoint Web Application.
*Note: Microsoft is providing this information as a convenience to you. The sites are not controlled by Microsoft. Microsoft cannot make any representations regarding the quality, safety, or suitability of any software or information found there. Please make sure that you completely understand the risk before retrieving any suggestions from the above link. *
If an Answer is helpful, please click "Accept Answer" and upvote it.
**Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread. **