0

Scenario: I am migrating a bunch of apps to the cloud and I'm trying to justify if they are being used before I rewrite them (they are oooooold). We are in SP2013 on-prem currently,

Problem: I need to know what pages the Apps have been placed on. I was able to get a report of the sites that the App is installed on, but that doesn't actually give me usage, since the app can be added to the site, but not be placed on a page.

My ask: Can anyone give me a PowerShell script that will pull pages the custom apps are installed on? I have both Googled and explicitly searched on Stack, but am either using the wrong phrasing or it can't be done. Your assistance in advance is greatly appreciated.

1

Try out this script by Salaudeen Rajack. He's got a couple scripts here that allow you to search your farm for uses of WebParts. Incase the URL breaks, here's the script to export all WebParts to a CSV. You can make it into a table in excel and filter by the webpart type you want, or by URL, etc.

Add-PSSnapin Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue

#Configuration parameters
$SiteURL = "http://site.company.com/"
$ReportOutput="$env:USERPROFILE\desktop\export.csv" 

$ResultCollection = @()

#Get All Subsites in a site collection and iterate through each
$Site = Get-SPSite $SiteURL
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)
            {
                $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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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