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.

SharePoint Server Development
SharePoint Server Development
SharePoint Server: A family of Microsoft on-premises document management and storage systems.Development: The process of researching, productizing, and refining new or existing technologies.
1,575 questions
Windows Server PowerShell
Windows Server PowerShell
Windows Server: A family of Microsoft server operating systems that support enterprise-level management, data storage, applications, and communications.PowerShell: A family of Microsoft task automation and configuration management frameworks consisting of a command-line shell and associated scripting language.
5,381 questions
0 comments No comments
{count} votes

Accepted answer
  1. Echo Du_MSFT 17,116 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