SharePoint Online allows organizations to deploy and manage custom apps through an App Catalog. A Site Collection App Catalog enables app deployment at the site collection level rather than at the tenant-wide level, providing more flexibility. Managing the Site Collection App Catalog using PnP PowerShell simplifies administration, making app deployment and management more efficient.
This guide will walk you through the step-by-step process of enabling, managing, and deploying apps in a Site Collection App Catalog using PnP PowerShell.
Prerequisites
Before proceeding, ensure you have the following:
- SharePoint Admin Permissions: You must be a SharePoint Administrator or Site Collection Administrator.
- PnP PowerShell Installed: If not installed, run the following command in PowerShell (run as Administrator):
Install-Module -Name PnP.PowerShell -Force -AllowClobber
- Connect to SharePoint Online: You need the SharePoint Online Management Shell or PowerShell Core.
Step 1: Connect to SharePoint Online
To manage SharePoint Site Collection App Catalogs, you need to establish a connection with SharePoint Online.
Command to Connect
Connect-PnPOnline -Url "https://yourtenant-admin.sharepoint.com" -Interactive
- Replace yourtenant with your actual SharePoint tenant name.
- The
-Interactive
flag prompts you to sign in using Multi-Factor Authentication (MFA).
Alternatively, if using credentials:
$cred = Get-Credential
Connect-PnPOnline -Url "https://yourtenant-admin.sharepoint.com" -Credentials $cred
Step 2: Enable Site Collection App Catalog
By default, the App Catalog is enabled at the tenant level, but we need to activate it for a specific site collection.
Command to Enable App Catalog on a Site Collection
Enable-PnPSiteCollectionAppCatalog -Site "https://yourtenant.sharepoint.com/sites/yoursite"
- Replace
"https://yourtenant.sharepoint.com/sites/yoursite"
with your site collection URL. - This command enables the App Catalog for the specific site collection.
Verification
To check if the App Catalog has been enabled successfully, open the site collection and navigate to:
Site Contents > Apps for SharePoint
Step 3: Upload an App to the Site Collection App Catalog
After enabling the Site Collection App Catalog, you can now upload SharePoint Framework (SPFx) or custom apps to it.
Command to Upload an App
Add-PnPApp -Path "C:\Apps\yourapp.sppkg" -Scope Site
- Replace
"C:\Apps\yourapp.sppkg"
with the actual path of your app package. - The
-Scope Site
ensures the app is deployed at the site collection level.
Verification
- Navigate to Site Contents > Apps for SharePoint.
- Ensure the uploaded app is visible.
Step 4: Deploy the Uploaded App
After uploading the app, you need to deploy it to allow users to install and use it.
Command to Deploy the App
Publish-PnPApp -Identity "yourapp.sppkg" -Scope Site
- Replace
"yourapp.sppkg"
with the actual app name.
Alternatively, if you don’t know the app’s name, list all available apps:
Get-PnPApp -Scope Site
Step 5: Install the App on the Site
Once deployed, install the app to make it available on the site.
Command to Install the App
Install-PnPApp -Identity "yourapp.sppkg" -Scope Site
- This makes the app available for users in the site collection.
Verification
- Go to Site Contents > Apps and check if the app is installed.
Step 6: Manage Apps (Update, Remove, List)
Once apps are installed, you can manage them using PnP PowerShell.
List Installed Apps
Get-PnPApp -Scope Site
- This lists all apps installed in the site collection.
Update an App
If an updated version of an app is available, you can update it:
Update-PnPApp -Identity "yourapp.sppkg" -Scope Site
Remove an App
To uninstall and remove an app from the Site Collection App Catalog:
Remove-PnPApp -Identity "yourapp.sppkg" -Scope Site -Force
- The
-Force
parameter ensures that no confirmation is required.
Step 7: Disable Site Collection App Catalog (If Needed)
If you need to disable the Site Collection App Catalog, use the following command:
Disable-PnPSiteCollectionAppCatalog -Site "https://yourtenant.sharepoint.com/sites/yoursite"
- This removes the App Catalog feature from the specific site collection.
Troubleshooting Common Issues
Issue 1: PnP PowerShell Module Not Recognized
If you get an error like The term 'Connect-PnPOnline' is not recognized
, install or update the module:
Update-Module -Name PnP.PowerShell
Issue 2: Permission Denied
If you receive permission errors, ensure:
- You are a SharePoint Admin.
- You connect using the correct tenant admin URL (
-Url "https://yourtenant-admin.sharepoint.com"
).
Issue 3: App Not Visible After Installation
- Ensure you deployed the app before installing it.
- Check the Apps for SharePoint library in Site Contents.