pnp / PnP-PowerShell

SharePoint PnP PowerShell CmdLets
https://pnp.github.io/powershell
Other
988 stars 665 forks source link

Add-PnPFile Failing on Modern Site with an Office 365 Group #1684

Open stvpwrs opened 6 years ago

stvpwrs commented 6 years ago

Reporting an Issue or Missing Feature

When attempting to use Add-PnPFile on a modern SharePoint team site with an Office 365 Group, like the following snippet:

$uploadReport = Add-PnPFile -Path $path -Folder "Documents"

the following error occurs:

Add-PnPFile : Access denied. You do not have permission to perform this action or access this resource.

This issue does not occur when using Add-PnPFile to upload files to a classic SharePoint site without an Office 365 Group.

The user account being used has the following permissions:

Expected behavior

The Add-PnPFile cmdlet should successfully upload the file to the designated document library/folder.

Actual behavior

The Add-PnPFile cmdlet fails with the following error:

Add-PnPFile : Access denied. You do not have permission to perform this action or access this resource.

Steps to reproduce behavior

$username = Read-Host -Prompt "Enter username as full email adress";
$securePassword = Read-Host -Prompt "Enter password" -AsSecureString;
$credential = New-Object System.Management.Automation.PSCredential ($username, $securePassword);

$destinationSite = <url of modern site with an Office 365 Group>

$Connection = Connect-PnPOnline -url $destinationSite -Credentials $credential

$path = <path to local file>

$uploadedReport = Add-PnPFile -Path $path -Folder "Documents"

Which version of the PnP-PowerShell Cmdlets are you using?

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

SharePointPnPPowerShellOnline 2.27.1806.1

How did you install the PnP-PowerShell Cmdlets?

DamienFloody commented 6 years ago

I have tried the same and if I change the library from "Documents" to ""Shared Documents" it works.

stvpwrs commented 6 years ago

@floodycarlow OK so that does work! So I am unclear if I was just reading documentation wrong? Example 6 on this doc page seems to be the Title of the library in the example.

DamienFloody commented 6 years ago

@stvpwrs Yes the same happened to me a while ago, not sure if I read the doc incorrectly or maybe it needs more clarification.

mavericksevmont commented 5 years ago

Struggled with the same as well, docu's need an update, this works for me