GitHub Icon Image

Add App Catalog to SharePoint site

Summary

When you just want to deploy certain SharePoint solution to a specific site, it's required to create an app catalog for that site. The below script will create it for the site. In the article referenced above you can check where you can use App catalog for the site instead of global app catalog.

Example Screenshot

  • CLI for Microsoft 365 using PowerShell
  • PnP PowerShell
  • SPO Management Shell

$site = "https://contoso.sharepoint.com/sites/site"
m365 login
m365 spo site appcatalog add --url $site
Write-output "App Catalog Created on " $site

Check out the CLI for Microsoft 365 to learn more at: https://aka.ms/cli-m365


$site = "https://contoso.sharepoint.com/sites/site"
Connect-PnPOnline $site
Add-PnPSiteCollectionAppCatalog -Site $site
Write-output "App Catalog Created on " $site

Check out the PnP PowerShell to learn more at: https://aka.ms/pnp/powershell


$AdminSiteURL = "https://domain-admin.sharepoint.com"
$Username = "chandani@domain.onmicrosoft.com"
$Password = "******"
$SecureStringPwd = $Password | ConvertTo-SecureString -AsPlainText -Force 
$Cred = New-Object System.Management.Automation.PSCredential -ArgumentList $Username, $SecureStringPwd

Function Login() {
    [cmdletbinding()]
    param([parameter(Mandatory = $true, ValueFromPipeline = $true)] $creds)
    Write-Host "Connecting to Tenant Admin Site '$($AdminSiteURL)'" -f Yellow   
    Connect-SPOService -url $AdminCenterURL -Credential $Cred
    Write-Host "Connection Successfull" -f Green 
}

Function AddAppCatalogToSiteCollection {
    $SiteURL = Read-Host "Enter Site URL"
    $Site = Get-SPOSite $SiteURL 
    Write-Host "Adding SharePoint site collection app catalog..." -f Yellow
    Add-SPOSiteCollectionAppCatalog -Site $Site
    Write-Host "Added SharePoint site collection app catalog successfully..." -f Green
}

Function StartProcessing {
    Login($Cred);
    AddAppCatalogToSiteCollection
}

StartProcessing

Check out the SPO Management Shell to learn more at: Introduction SharePoint Online Management Shell | Microsoft Docs

Source Credit

Sample first appeared on https://pnp.github.io/cli-microsoft365/sample-scripts/spo/add-app-catalog/

Contributors

Author(s)
David Ramalho
Paul Bullock
Chandani Prajapati

Disclaimer

THESE SAMPLES ARE PROVIDED AS IS WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT.

Back to top Script Samples
Generated by DocFX with Material UI