Wednesday, May 3, 2017

List of all web parts used on SharePoint 2013 pages using PowerShell

The following PowerShell will give text file for all web parts found on existing pages of SharePoint 2013.

[void][System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint")

[void][System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint.Publishing")

 function ListWebParts($web) {

if ([Microsoft.SharePoint.Publishing.PublishingWeb]::IsPublishingWeb($web))

{

$webPublish = [Microsoft.SharePoint.Publishing.PublishingWeb]::GetPublishingWeb($web)

$pages = $webPublish.GetPublishingPages()

 

foreach($page in $pages)

{

$manager = $web.GetLimitedWebPartManager($page.Url, [System.Web.UI.WebControls.WebParts.PersonalizationScope]::Shared)

$webCollection = $manager.WebParts

if($webCollection.Count -ne 0)

{

for($i =0;$i -lt $webCollection.Count; $i++)

{

$sw.writeline($web.url + "/" + $page.url + ";" + $webCollection[$i].GetType().Name + ";" +    $webCollection[$i].Title)

}

}

}

}

}

 

function LoadSPSite()

{

$siteURL = "http://www.sharepointsitepath/"

$site = New-Object Microsoft.SharePoint.SPSite($siteURL)

 

foreach($web in $site.allwebs)

{

write-output $web.Title

ListWebParts($web)

}

$site.Dispose()

}

 

$sw = [System.IO.StreamWriter] "C:\UsedControls\UsedControlDetails.txt"

$sw.writeline("Page URL;Web Part Type;Web Part Title")

LoadSPSite

$sw.close()

Thank you very much

          Fahadullah Karimi

         SharePoint Specialist


Error: The tool was unable to download Microsoft SQL Server 2012 Native Client. Please check your Internet connection and try again. SharePoint 2016 Prerequisite installer. Best Practice for disposing objects in SharePoint Development

6 comments:

  1. It's interesting that many of the bloggers to  helped  clarify a few things for me as well as giving.Most of ideas can be nice content.The people to give them a good shake to get your point and across the command.
    Sharepoint Training in Chennai

    ReplyDelete
  2. The components for the search provisioning which is really impressive and interesting. Thanks for sharing the information on webparts used on sharepoint.

    ReplyDelete
  3. worlds most popular blog about tips & tricks this blog provide all kind of tips & tricks like mobile, desktop, windows, google, java, sql, oracle, html, maths, science, english, hindi, blogs, websites games and much more..
    https://mkbloggers.blogspot.in/

    ReplyDelete
  4. No need to worry if you are facing trouble with your software you just away from your solution. If you want more information you can get touch with trained experts via Quickbooks Desktop support Customer services. keep itup guys
    Ai & Artificial Intelligence Course in Chennai
    PHP Training in Chennai
    Ethical Hacking Course in Chennai Blue Prism Training in Chennai
    UiPath Training in Chennai

    ReplyDelete