powershell icon indicating copy to clipboard operation
powershell copied to clipboard

[BUG] Running SetSiteVersionPolicy with App Permissions throws error

Open sympmarc opened this issue 5 months ago • 2 comments

Reporting an Issue or Missing Feature

When I run SetSiteVersionPolicy with App Permissions, I get an error: "Cannot call this API with an app-only principal."

The actual call is this:

Set-PnPSiteVersionPolicy -Connection $siteConnection -EnableAutoExpirationVersionTrim $true -ApplyToExistingDocumentLibraries -ApplyToNewDocumentLibraries

Expected behavior

Actual behavior

I've tested, and I believe it's a false error. The cmdlet seems to have the desired effect, in that a new Doc Lib created in the site right after running the cmdlet gets Automatic Versioning. (It can take up to 24h for it to take effect on existing libs.)

What is the version of the Cmdlet module you are running?

3.1.0

Which operating system/environment are you running PnP PowerShell on?

  • [x] Windows
  • [ ] Linux
  • [ ] MacOS
  • [ ] Azure Cloud Shell
  • [ ] Azure Functions
  • [ ] Other : please specify

sympmarc avatar Sep 30 '25 19:09 sympmarc

Wondering whether you tried it with the nightly build. I can't reproduce the misleading error with PnP PowerShell module version 3.1.91.

reshmee011 avatar Oct 10 '25 13:10 reshmee011

Any luck trying the latest PnP PowerShell version?

reshmee011 avatar Nov 29 '25 19:11 reshmee011