I am trying to check if the content editor or script editor web part is present on the list forms (NewForm, EditForm, DisplayForm) in SharePoint 2013.

I can get the web part type from web part page using following commands:

$webPartXml  =  [xml](Get-PnPWebPartXml -ServerRelativePageUrl $ServerRelativePageUrl -Identity $wpId)
$webPartType = $webPartXml.WebPart.TypeName

But seems like this is not applicable for list forms.

Is there any way I can check if these web parts are present on the list forms.

Note : Due to restrictions I cannot write server side code.

1 Answer 1


This script will get all the editForm webparts and export it to a csv file. From there you can filter down for Script Editor and Content Editor Web Parts in the csv file. To get NewForm or DisplayForm update the script to look at DefaultNewFormUrl or DefaultDisplayFormUrl.

Add-PSSnapin Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue
#Configuration parameters
$SiteURL = "http://my.sharepoint.com"

$ResultCollection = @()
#Get All Subsites in a site collection and iterate through each
$Site = Get-SPSite $SiteURL

ForEach($Web in $Site.AllWebs)
    Write-host -f Yellow "Processing Site: "$Web.URL
    #Get all lists - Exclude Hidden System lists
    $ListCollection = $web.lists | Where-Object  { ($_.hidden -eq $false) -and ($_.IsSiteAssetsLibrary -eq $false)}

    ForEach ($list in $ListCollection) {
        $PagesLib = $Web.Lists[$list]

        # Get Default Edit form URL   (DefaultNewFormUrl, DefaultDisplayFormUrl)
        $form = $PagesLib.DefaultEditFormUrl
        $PageURL = $Web.site.Url+$form+"?DisplayMode=Design"

        $ASPXPage = $Web.GetFile($form)
        $WebPartManager = $ASPXPage.GetLimitedWebPartManager([System.Web.UI.WebControls.WebParts.PersonalizationScope]::Shared)
        #Get All Web Parts data
        foreach ($WebPart in $WebPartManager.WebParts)
            $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

PowerShell to list all web parts used in the root default.aspx

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.