SharePoint 2010 Custom Solution Site Usage Report

Nguyen, Tee 106 Reputation points
2021-02-11T05:12:04.13+00:00

We had old SharePoint 2010 site with few custom solutions deployed. There are about 1500 site collections. We would like to run PowerShell report to show if these custom solutions were used in any site collections at all. Is this possible? If yes, please provide PS code that we can use. Thanks Tee

SharePoint Server Management
SharePoint Server Management
SharePoint Server: A family of Microsoft on-premises document management and storage systems.Management: The act or process of organizing, handling, directing or controlling something.
2,949 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. ChelseaWu-MSFT 6,326 Reputation points
    2021-02-12T03:11:30.937+00:00

    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. **


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.