Help with Uploading Files to SharePoint Using PnP PowerShell

0
1
Asked By CoolPineapple97 On

I'm working with PnP PowerShell to upload files to a SharePoint library after setting up a new App registration. I can connect using a certificate without any issues, and the app has the permissions Sites.Manage.All and Sites.ReadWrite.All, which should allow it to interact with all SharePoint sites. While I can delete files and folders on two sites, I'm facing an 'Access Denied' error when trying to upload a file using Add-PnPFile on another site. What could be the issue? Is there a setting I need to adjust on the SharePoint side?

4 Answers

Answered By CleverFox73 On

Have you checked the app permissions for both sites? You can verify them in the AppInv.aspx page by looking up your app ID. Make sure to add the following permission requests:

This approach can sometimes resolve access issues.

SmartPanda99 -

I found that I could upload files to a new document library without issues, but the default 'Documents' library was giving me the access denied message. No idea why, but just in case, when you reference the library in your script, use "Shared%20Documents" instead of just "Documents".

Answered By WittySparrow42 On

You might want to double-check if you're trying to upload the file to the 'Shared Documents' folder. Sometimes the specific library path matters when it comes to permissions.

Answered By HelpfulDolphin56 On

As a follow-up, I realized that the exact library name matters. Instead of using "Documents", you might want to reference it as "Shared%20Documents" to avoid access issues.

Answered By TechWhizKid21 On

PnP errors can be pretty vague. It sounds like this could be more about the document library settings rather than an issue with your script.

Related Questions

LEAVE A REPLY

Please enter your comment!
Please enter your name here

This site uses Akismet to reduce spam. Learn how your comment data is processed.