0

We have 5000+ SharePoint Online sites in our tenant where i have to change the Site Version setting to automatic for all existing document libraries.

I am using the below to connect using an Azure App and i get the error "Cannot call this API with an app-only principal."

When i use either -Interactive or -UseWebLogin for a single site, it does that job but i cannot login in to each site for 5000+ times. What is the solution here?

The Azure App has all the necessary permissions both from SharePoint Online (AllSites.FullControl - Delegated, Sites.FullControl.All - Application) and Graph API (Sites.FullControl.All) Perspective.

Connect-PnPOnline -Url $TenantURL -ClientID $ClientID -Tenant $TenantID -CertificateBase64Encoded $Cert
Set-PnPSiteVersionPolicy -EnableAutoExpirationVersionTrim $true -ApplyToExistingDocumentLibraries

1 Answer 1

0

Per my test, I could reproduce your issue, and after doing some research, I found that sharepoint doesn't support the cmdlet with app only permission currently. You could refer to the following link

https://github.com/pnp/powershell/issues/4240

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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