PnP PowerShell - Configure Site Collection App Catalog

Introduction

Previously, we were able to deploy all the SharePoint add-ins and SharePoint Framework (SPFx) solutions only in the tenant level app catalog. Because of this, it was visible to all the site collections available to that tenant. As a result, Microsoft introduced the site collection scoped app catalog. With the help of this, site collection administrators can now manage the scope of the solution deployments.

When we create a new site, the app catalog is not visible by default. But, we can enable/disable the app catalog using various approaches. In this article, we will be going through one of the approaches to configuring the app catalog using PnP PowerShell.

Prerequisites

You need to install PnP PowerShell Module in your local machine to run the cmdlets mentioned in this article.

The account used to enable or disable this must be a Site Collection Administrator’s account on both the tenant-level App Catalog and the target site.

Enable Site Collection App Catalog

# Url of the SharePoint Online Site Collection 
$SiteUrl = "https://hemantkabra.sharepoint.com/sites/mysite" 

# Connect to the SharePoint Online Site Collection
Write-Host "Connecting to Site Collection..!"
Connect-PnPOnline -Url $SiteUrl -Interactive

# Enable the Site Collection Scoped App Catalog
Write-Host "Enabling the Site Collection Scoped App Catalog..!"
Add-PnPSiteCollectionAppCatalog -Site $SiteUrl
Write-Host "Enabled the Site Collection Scoped App Catalog on - $($SiteUrl)"

# Disconnect the PnP Session
Disconnect-PnPOnline

Disable Site Collection App Catalog

# Url of the SharePoint Online Site Collection 
$SiteUrl = "https://hemantkabra.sharepoint.com/sites/mysite" 

# Connect to the SharePoint Online Site Collection
Write-Host "Connecting to Site Collection..!"
Connect-PnPOnline -Url $SiteUrl -Interactive

# Enable the Site Collection Scoped App Catalog
Write-Host "Disabling the Site Collection Scoped App Catalog..!"
Remove-PnPSiteCollectionAppCatalog -Site $SiteUrl
Write-Host "Disabled the Site Collection Scoped App Catalog on - $($SiteUrl)"

# Disconnect the PnP Session
Disconnect-PnPOnline

Important note

The script will not actually remove the app catalog list and its content from the site. It will still be visible, but it will not allow for the deployment of the new solutions.

List all the Site Collections where the app catalog is enabled

If you want to see the list of site collections where administrators have enabled the app catalog, use the following URL,

https://<tenant-app-catalog-URL>/Lists/SiteCollectionAppCatalogs/AllItems.aspx

Official Documentation

Please find below the official documents from the PnP community for more details about the cmdlets used in this article,

I hope you enjoyed reading this blog post. Please feel free to leave a comment in case you have any feedback, suggestions, or queries.