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.
Copied
$site = "https://contoso.sharepoint.com/sites/site"
Connect-PnPOnline $site
Add-PnPSiteCollectionAppCatalog -Site $site
Write-output "App Catalog Created on " $site
Copied
$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
Copied
# 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
Contributors
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.