Export all apps from all sitesollection app catalogs from SharePoint

Straightforward PowerShell script designed to export all the Apps added in all the Site Collection App Catalogs by utilizing PnP PowerShell

In the fast-paced world of data management and automation, the ability to export data efficiently is a skill highly required by professionals across various fields. Fortunately, PowerShell scripts offer a powerful solution to streamline this process, allowing users to extract and manipulate data with ease.

Here’s a simple PowerShell script that assists in exporting the list of all the apps added to the Site Collection App Catalogs across the entire Tenant by utilising PnP PowerShell.

PnP PowerShell version used:2.4.63-nightly
$siteurl = "https://<tenant>-admin.sharepoint.com"
Connect-PnPOnline $siteurl -Interactive
Write-Host "Script exceution started"
$sites = Get-PnPSiteCollectionAppCatalog 
if ($site.length -gt 0) {
    $results = @()
    foreach ($site in $sites) {
        Write-Host "**** " $site.AbsoluteUrl "*****"
        # Estalibing connection to the Site Collection
        $connection = Connect-PnPOnline $site.AbsoluteUrl -Interactive
        try {
            # Fetches all the apps added in the Site Collection App Catalog
            $apps = Get-PnPApp -Scope Site -Connection $connection
            Write-Host $apps.length " apps found."
            if ($apps.length -gt 0) {
                foreach ($app in $apps) {
                    
                    $results += [pscustomobject][ordered]@{
                        Site              = $site.AbsoluteUrl
                        ID                = $app.Id
                        Title             = $app.Title
                        Deployed          = $app.Deployed
                        AppCatalogVersion = $app.AppCatalogVersion
                        InstalledVersion  = $app.InstalledVersion
                        Status            = $app.status
                        Remarks           = ""
                    }
                }
            }
            else {
                $results += [pscustomobject][ordered]@{
                    Site              = $site.AbsoluteUrl
                    ID                = ""
                    Title             = ""
                    Deployed          = ""
                    AppCatalogVersion = ""
                    InstalledVersion  = ""
                    Status            = ""
                    Remarks           = "No items available"
                }
            }
        }
        catch {
            
            Write-Warning $_.Exception.Message
            $results += [pscustomobject][ordered]@{
                Site              = $site.AbsoluteUrl
                ID                = ""
                Title             = ""
                Deployed          = ""
                AppCatalogVersion = ""
                InstalledVersion  = ""
                Status            = ""
                Remarks           = $_.Exception.Message
            }
        }
    }
    $results | Export-Csv -Path "allsitecollectionapps.csv" -NoTypeInformation
}
Write-Host "Script execution completed."

 

The above script executes and iterates all the Site Collections which has App Catalogs along with Apps added. Then it exports in to the csv file in current running path.
Note: The user who runs the script, should have access to all the Site Collections. Other wise it returns an error says “Attempted to perform an unauthorized operation.”

Shantha Kumar
Shantha Kumar
Articles: 295

Leave a Reply

Your email address will not be published. Required fields are marked *