GitHub Icon Image
GitHub

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

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

$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


# SharePoint online site URL
$siteUrl = "https://contoso.sharepoint.com/sites/SPConnect"

# Get Credentials to connect
$m365Status = m365 status
if ($m365Status -match "Logged Out") {
   m365 login
}

# Add site collection app catalog
m365 spo site appcatalog add --siteUrl $siteUrl

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

Contributors

Author(s)
Paul Bullock
Chandani Prajapati
Ganesh Sanap

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