Add-PNPFile : The remote server returned an error: (401) Unauthorized. #1912
Replies: 3 comments 5 replies
-
I’m going to guess as you haven’t provided the exact command you are trying to use. If you are writing to a default document library, the main folder is actually called |
Beta Was this translation helpful? Give feedback.
-
Hi, I'm using this command to upload files to sharepoint with Pnp. Add-PNPFile -Path "C:\M2\powershell-sharepoint.txt" -folder "testscript" |
Beta Was this translation helpful? Give feedback.
-
I'm having the same problem. If I use a global admin account it works fine. If I use an App Registration account with a secret or cert, I get the 401 error. The app account started with the Sites.Selected graph API permission, but I upped it to Sites.FullControl.All and still the same error. Deleted the app account and started over and still the same. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Im trying to upload files to sharepoint online with powershell PnP commands and modern auth.
Can connect succesfully to my site (https://lci2.sharepoint.com/sites/MarcoTestSite)
but when try to upload files with Add-PNPFile the powershell console show this error: Add-PNPFile : The remote server returned an error: (401) Unauthorized.
can you help me to fix this?
Beta Was this translation helpful? Give feedback.
All reactions