To know on which web site, a particular web part / feature is running using Powershell

Sanjay Chauhan 61 Reputation points
2022-01-20T18:09:11.207+00:00

Hi,

I want to know which web site under a web application is running a particular web part Or feature using PowerShell.

SharePoint OnPrem 2013

Thanks in Advance.

Microsoft 365 and Office | SharePoint Server | Development
Windows for business | Windows Server | User experience | PowerShell
0 comments No comments
{count} votes

Accepted answer
  1. Echo Du_MSFT 17,316 Reputation points
    2022-01-21T06:54:18.077+00:00

    Hi @Sanjay Chauhan ,

    Welcome to Q&A Forum!

    You can run the following PowerShell script to get which sites in your web application use a specific webpart.

    Note: In my test, I want to find all "Get started with your site" web part in SharePoint 2013

    Add-PSSnapin Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue  
       
    #Configuration parameters  
    $SiteURL = "http://sp"  
    $ReportOutput="C:\temp\Webparts-in-use.csv"  
       
    $ResultCollection = @()  
      
    #Get All Site Collections in the web application  
    $Sites = Get-SPWebApplication $WebAppURL | Get-SPSite  
      
    #Iterate through each Site collection  
    ForEach($Site in $Sites)  
    {  
        ForEach($Web in $Site.AllWebs)  
        {  
            write-host Processing $Web.URL  
            #If the Current Web is Publishing Web  
            if ([Microsoft.SharePoint.Publishing.PublishingWeb]::IsPublishingWeb($Web))  
            {  
                #Get the Publishing Web  
                $PubWeb = [Microsoft.SharePoint.Publishing.PublishingWeb]::GetPublishingWeb($Web)  
                         
                #Get the Pages Library  
                $PagesLib = $PubWeb.PagesList  
             }  
             else  
             {  
                $PagesLib = $Web.Lists["Site Pages"]  
             }              
                #Iterate through all Pages   
                foreach ($Page in $PagesLib.Items | Where-Object {$_.Name -match ".aspx"})  
                {  
                    $PageURL=$web.site.Url+"/"+$Page.File.URL  
                    $WebPartManager = $Page.File.GetLimitedWebPartManager([System.Web.UI.WebControls.WebParts.PersonalizationScope]::Shared)  
                       
                    #Get All Web Parts data  
                    ForEach ($WebPart in $WebPartManager.WebParts | Where-Object { $_.GetType().ToString() -like "*started*"} )  
                    {  
                        $Result = New-Object PSObject  
                        $Result | Add-Member -type NoteProperty -name "Site URL" -value $web.Url  
                        $Result | Add-Member -type NoteProperty -name "Page URL" -value $PageURL  
                        $Result | Add-Member -type NoteProperty -name "Web Part Title" -value $WebPart.Title  
                        $Result | Add-Member -type NoteProperty -name "Web Part Type" -value $WebPart.GetType().ToString()  
       
                        $ResultCollection += $Result  
                    }  
                }  
        }    
    }  
      
    #Export results to CSV  
    $ResultCollection | Export-csv $ReportOutput -notypeinformation  
    

    167010-p1.jpg

    167027-p2.jpg

    Can you tell if the feature you are talking about refers to Site Collection features or Site features? More information, see "List of Site Collection Features on SharePoint 2013 and Office 365" article.

    Thanks,
    Echo Du

    ==================================

    If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
    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.

    1 person found this answer helpful.

0 additional answers

Sort by: Most helpful

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.