2

I am using below PnP PowerShell command to add site collection level application catalog and giving me an Unauthorized error. I currently have owner access to the site.

PowerShell

$siteUrl = "https://site/"
Connect-PnPOnline $siteUrl

$site = Get-PnPSite

Add-PnPSiteCollectionAppCatalog -Site $site

ERROR

Add-PnPSiteCollectionAppCatalog : The remote server returned an error: (401) Unauthorized. At line:6 char:1 + Add-PnPSiteCollectionAppCatalog -Site $site + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : WriteError: (:) [Add-PnPSiteCollectionAppCatalog], WebException + FullyQualifiedErrorId : EXCEPTION,SharePointPnP.PowerShell.Commands.Admin.AddSiteCollectionAppCatalog

Does 'Add-PnPSiteCollectionAppCatalog' command require more access or is this access enough for this command.

EDIT

Because I was getting this error I tried the same on Developer Tanet where I am an admin on the tenant which give me below error.

Add-PnPSiteCollectionAppCatalog : Cannot invoke method or retrieve property from null object. Object returned by the following call stack is null. "TenantAppCatalog RootWeb GetSiteByUrl new Microsoft.Online.SharePoint.TenantAdministration.Tenant() " At C:\Ravi\SPO\PowerShell\Add-SiteCollectionLevelAppCatalog.ps1:8 char:1 + Add-PnPSiteCollectionAppCatalog -Site $site + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : WriteError: (:) [Add-PnPSiteCollectionAppCatalog], ServerException + FullyQualifiedErrorId : EXCEPTION,SharePointPnP.PowerShell.Commands.Admin.AddSiteCollectionAppCatalog

2

1) You need SharePoint tenant admin access to enable Site collection app catalog. It is assumed that the we already have a tenant app catalog. If its not present, you need to create that first and then run the PS to add SCA.

2) Add-PnPSiteCollectionAppCatalog commandlet accepts the parameter Site which can be a string or Site object .

So, you can also use the command as below:

Add-PnPSiteCollectionAppCatalog -Site 
"https://your-tenant-name.sharepoint.com/sites/testSiteCollection"

References -

Using Site collection app catalog

Add-PnPSiteCollectionAppCatalog

  • You are partially correct. 1) Correct on this. I was also facing some other error on my development tenant. The reason for the error was, in development tenant I did not have Tenant Level Application Catalog and because of that, I could not create Site Collection Level Application Catalog. 2) Add-PnPSiteCollectionAppCatalog can have site object as a parameter. If you look at the example on the link that you shared uses site object and not the url. – Ravi Khambhati Jun 8 '18 at 2:50
  • @RaviKhambhati - thanks, corrected. Could please mark it as answer if it helped you ? – Gautam Sheth Jun 8 '18 at 5:13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.