Enable Site Collection App Catalog on a specific sites using CSV
Enable Site Collection App Catalog on list of SharePoint sites from CSV
Summary
The script reads list of SharePoint site collection URLs from a CSV and enables the Site collection app catalog on them.

Implementation
- Create csv file with the list of site collection URLs to enable app catalog
- Open Windows PowerShell ISE
- Create a new file
- Copy the code below
- Save the file and run it
- Make sure you must have access to the app catalog to apply
# Example: .\Enable-SiteCollectionAppCatalog.ps1 -AdminUrl "https://contoso-admin.sharepoint.com" -CsvPath ".\SiteURLs.csv"
[CmdletBinding()]
param (
[Parameter(Mandatory = $true, HelpMessage = "URL of the SharePoint Admin Center, e.g.https://contoso-admin.sharepoint.com")]
[string]$AdminUrl,
[Parameter(Mandatory = $false, HelpMessage = "Path to CSV file with list of SharePoint sites to enable Site Collection App Catalog")]
[string]$CsvPath = ".\SiteURLs.csv"
)
begin {
Write-Host "Connecting to SharePoint Admin Site '$($AdminUrl)'" -f Yellow
Connect-SPOService -Url $AdminUrl
}
process {
$data = Import-Csv -Path $CsvPath
$data | Foreach-Object{
Write-Host "Adding site collection app catalog to site '$($_.SiteUrl)'..." -f Yellow
$site = Get-SPOSite $_.SiteUrl
Add-SPOSiteCollectionAppCatalog -Site $site
}
}
end {
Disconnect-SPOService
Write-Host "Finished" -ForegroundColor Green
}# Example: .\Enable-SiteCollectionAppCatalog.ps1 -AdminUrl "https://contoso-admin.sharepoint.com" -CsvPath ".\SiteURLs.csv"
[CmdletBinding()]
param (
[Parameter(Mandatory = $true, HelpMessage = "URL of the SharePoint Admin Center, e.g.https://contoso-admin.sharepoint.com")]
[string]$AdminUrl,
[Parameter(Mandatory = $false, HelpMessage = "Path to CSV file with list of SharePoint sites to enable Site Collection App Catalog")]
[string]$CsvPath = ".\SiteURLs.csv"
)
begin {
Write-Host "Connecting to SharePoint Admin Site '$($AdminUrl)'" -f Yellow
Connect-PnPOnline -Url $AdminUrl
}
process {
$data = Import-Csv -Path $CsvPath
$data | Foreach-Object{
Write-Host "Adding site collection app catalog to site '$($_.SiteUrl)'..." -f Yellow
Add-PnPSiteCollectionAppCatalog -Site $_.SiteUrl
}
}
end {
Disconnect-PnPOnline
Write-Host "Finished" -ForegroundColor Green
}# Example: .\Enable-SiteCollectionAppCatalog.ps1 -CsvPath ".\SiteURLs.csv"
[CmdletBinding()]
param (
[Parameter(Mandatory = $false, HelpMessage = "Path to CSV file with list of SharePoint sites to enable Site Collection App Catalog")]
[string]$CsvPath = ".\SiteURLs.csv"
)
begin {
#Log in to Microsoft 365
Write-Host "Connecting to Tenant" -f Yellow
$m365Status = m365 status
if ($m365Status -match "Logged Out") {
m365 login
}
Write-Host "Connection Successful!" -f Green
}
process {
$data = Import-Csv -Path $CsvPath
$data | Foreach-Object{
Write-Host "Adding site collection app catalog to site '$($_.SiteUrl)'..." -f Yellow
m365 spo site appcatalog add --siteUrl $_.SiteUrl
}
}
end {
m365 logout
Write-Host "Finished" -ForegroundColor Green
}SiteUrl
https://contoso.sharepoint.com/sites/Audits
https://contoso.sharepoint.com/sites/Finance
https://contoso.sharepoint.com/sites/HR
https://contoso.sharepoint.com/sites/Innovations
https://contoso.sharepoint.com/sites/RetailContributors
| Author(s) |
|---|
| Nanddeep Nachan |
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.
Tool documentation & references
- Introduction to the SharePoint Online Management Shell
Check out the SPO Management Shell documentation site to get started and for the reference to the cmdlets.
- Want to learn more about PnP PowerShell and the cmdlets
Check out the PnP PowerShell site to get started and for the reference to the cmdlets.
- Want to learn more about CLI for Microsoft 365 and the commands
Check out the CLI for Microsoft 365 site to get started and for the reference to the commands.