You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am currently trying to Add-PnPFile to a site. But I am getting the following error:
The remote server returned an error: (401) Unauthorized.
I have given the system identity Microsoft Graph Sites.Selected Permission
I then used the Grant-PnPAzureADAppSitePermission to give it a write permission to the site. I upgraded it to have fullcontrol permission but I am still getting the same error.
Please include complete script or code samples in-line or linked from gists
To give Microsoft graph permission
To give fullcontol permission to Site Set-PnPAzureADAppSitePermission -PermissionId xxxxxxxxxxxx -Permissions FullControl -Site https://xxxxx.sharepoint.com/sites/xxxxxx
PnP Script to Add file
Connect-PnPOnline -url "https://xxxxx.sharepoint.com/sites/xxxxx" -ManagedIdentity
$logoutput= "This is a test"
Add-PnPFile -FileName "log$($date).txt" -Folder "Shared Documents" -Content $logoutput
What is the version of the Cmdlet module you are running?
This is the version of pnp powershell used to grant permission:
This discussion was converted from issue #3250 on July 06, 2023 15:36.
Heading
Bold
Italic
Quote
Code
Link
Numbered list
Unordered list
Task list
Attach files
Mention
Reference
Menu
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
I am currently trying to Add-PnPFile to a site. But I am getting the following error:
The remote server returned an error: (401) Unauthorized.
I have given the system identity Microsoft Graph Sites.Selected Permission
I then used the Grant-PnPAzureADAppSitePermission to give it a write permission to the site. I upgraded it to have fullcontrol permission but I am still getting the same error.
Please include complete script or code samples in-line or linked from gists
To give Microsoft graph permission
To grant permission to Site
To give fullcontol permission to Site
Set-PnPAzureADAppSitePermission -PermissionId xxxxxxxxxxxx -Permissions FullControl -Site https://xxxxx.sharepoint.com/sites/xxxxxx
PnP Script to Add file
What is the version of the Cmdlet module you are running?
This is the version of pnp powershell used to grant permission:
ModuleType Version Name ExportedCommands
Manifest 1.12.0 PnP.PowerShell {Add-PnPAdaptiveScopeProperty, Add-PnPPropertyBagValue, Add-PnPSiteClassification, Copy-PnPFolder...}
This is the version the automation account has:
ModuleType Version PreRelease Name PSEdition ExportedCommands
Manifest 2.2.0 PnP.PowerShell Desk {Add-PnPAdaptiveScopeProperty, Add-PnPPr…
Which operating system/environment are you running PnP PowerShell on?
Beta Was this translation helpful? Give feedback.
All reactions