Access Denied on http://products.office.com/microsoft-stream page

%3CLINGO-SUB%20id%3D%22lingo-sub-425404%22%20slang%3D%22en-US%22%3EAccess%20Denied%20on%20%3CA%20href%3D%22http%3A%2F%2Fproducts.office.com%2Fmicrosoft-stream%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3Ehttp%3A%2F%2Fproducts.office.com%2Fmicrosoft-stream%3C%2FA%3E%20page%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-425404%22%20slang%3D%22en-US%22%3E%3CP%3EHi%2C%3C%2FP%3E%3CP%3EI%20have%20a%20problem%20with%26nbsp%3BAdd-PnPFile.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI%20have%20two%20users%3A%3CBR%20%2F%3E-%20site%20administrator%20(it's%20me%20-%20logged%20in%20on%20the%20local%20machine)%3CBR%20%2F%3E-%20regular%20user.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EBoth%20users%20have%20write%20rigths%20to%20sharepoint%20library%3A%20both%20users%20can%20edit%20the%20library%20using%20sharepoint%20user%20interface%20(web).%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EBelow%20is%20a%20script%20which%3A%3CBR%20%2F%3E-%20works%20perfectly%20when%20I%20connect%20to%20the%20sharepoint%20as%20site%20adminstrator%2C%3CBR%20%2F%3E-%20fails%20when%20I%20connect%20to%20the%20sharepoint%20with%20second%20(regular)%20user%20with%20permission%20denied%20(as%20below).%3C%2FP%3E%3CP%3EIs%20there%20any%20specific%20sharepoint%20rights%20that%20allow%20the%20user%20to%20make%20REST%20API%20calls%20(I%20understand%20they%20are%20used%20by%20PnP%20scripts)%3F%3C%2FP%3E%3CP%3E---%3C%2FP%3E%3CP%3E%2B%20Add-PnPFile%20-Path%20test.txt%20-Folder%20%22Shared%20Documents%5CSMS_Export%22%5C%3CBR%20%2F%3E%2B%20~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~%3CBR%20%2F%3E%26nbsp%3B%20%26nbsp%3B%20%2B%20CategoryInfo%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%3A%20InvalidArgument%3A%20(%3A)%20%5BAdd-PnPFile%5D%2C%20ParameterBindingException%3CBR%20%2F%3E%26nbsp%3B%20%26nbsp%3B%20%2B%20FullyQualifiedErrorId%20%3A%20PositionalParameterNotFound%2CSharePointPnP.PowerShell.Commands.Files.AddFile%3C%2FP%3E%3CP%3E---%3CBR%20%2F%3E%3CSPAN%3E%24Sharepoint_User%3D%22test%40domain.com%22%3CBR%20%2F%3E%3C%2FSPAN%3E%3CSPAN%3E%24Sharepoint_Pass%3D%22HERE_PASWORD%22%3CBR%20%2F%3E%3C%2FSPAN%3E%3CSPAN%3E%24PWord%3DConvertTo-SecureString%20-String%20%24Sharepoint_Pass%20-AsPlainText%20-Force%3CBR%20%2F%3E%3C%2FSPAN%3E%3CSPAN%3E%24Credential%20%3D%20New-Object%20-TypeName%20%22System.Management.Automation.PSCredential%22%20-ArgumentList%3CBR%20%2F%3E%3C%2FSPAN%3E%3CSPAN%3E%24Sharepoint_User%2C%24PWord%3C%2FSPAN%3E%3CBR%20%2F%3E%3C%2FP%3E%3CP%3E%3CSPAN%3E%23%20This%20method%20of%20connecting%20makes%20the%20following%20add-pnpfile%20to%20work%20OK%3C%2FSPAN%3E%3CSPAN%3E%23%20Connect-PnPOnline%20-Url%20%3CA%20href%3D%22https%3A%2F%2Fmysite.sharepoint.com%2Fsites%2Ftest%22%20target%3D%22_blank%22%20rel%3D%22nofollow%20noopener%20noreferrer%20noopener%20noreferrer%22%3Ehttps%3A%2F%2Fmysite.sharepoint.com%2Fsites%2Ftest%3C%2FA%3E%20-UseWebLogin%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%3CSPAN%3E%23%20And%20this%20method%20of%20connecting%20makes%20it%20fail.%3C%2FSPAN%3E%3CSPAN%3EConnect-PnPOnline%20-Url%20%3CA%20href%3D%22https%3A%2F%2Fmysite.sharepoint.com%2Fsites%2Ftest%22%20target%3D%22_blank%22%20rel%3D%22nofollow%20noopener%20noreferrer%20noopener%20noreferrer%22%3Ehttps%3A%2F%2Fmysite.sharepoint.com%2Fsites%2Ftest%3C%2FA%3E%20-Credentials%20%24Credential%3CBR%20%2F%3E%3C%2FSPAN%3E%3CSPAN%3Eecho%20%22ASDQWE%22%20%26gt%3B%20test.txt%3CBR%20%2F%3E%3C%2FSPAN%3E%3CSPAN%3EAdd-PnPFile%20-Path%20test.txt%20-Folder%20%22Shared%20Documents%5CTest%22%3CBR%20%2F%3E%3C%2FSPAN%3E%3CSPAN%3EGet-PnPFolderItem%20-FolderSiteRelativeUrl%20%22Shared%20Documents%5CTest%22%3C%2FSPAN%3E%3C%2FP%3E%3C%2FLINGO-BODY%3E
Highlighted
Occasional Visitor

Hi,

I have a problem with Add-PnPFile.

 

I have two users:
- site administrator (it's me - logged in on the local machine)
- regular user.

 

Both users have write rigths to sharepoint library: both users can edit the library using sharepoint user interface (web).

 

Below is a script which:
- works perfectly when I connect to the sharepoint as site adminstrator,
- fails when I connect to the sharepoint with second (regular) user with permission denied (as below).

Is there any specific sharepoint rights that allow the user to make REST API calls (I understand they are used by PnP scripts)?

---

+ Add-PnPFile -Path test.txt -Folder "Shared Documents\SMS_Export"\
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidArgument: (:) [Add-PnPFile], ParameterBindingException
    + FullyQualifiedErrorId : PositionalParameterNotFound,SharePointPnP.PowerShell.Commands.Files.AddFile

---
$Sharepoint_User="test@domain.com"
$Sharepoint_Pass="HERE_PASWORD"
$PWord=ConvertTo-SecureString -String $Sharepoint_Pass -AsPlainText -Force
$Credential = New-Object -TypeName "System.Management.Automation.PSCredential" -ArgumentList
$Sharepoint_User,$PWord

# This method of connecting makes the following add-pnpfile to work OK# Connect-PnPOnline -Url https://mysite.sharepoint.com/sites/test -UseWebLogin

# And this method of connecting makes it fail.Connect-PnPOnline -Url https://mysite.sharepoint.com/sites/test -Credentials $Credential
echo "ASDQWE" > test.txt
Add-PnPFile -Path test.txt -Folder "Shared Documents\Test"
Get-PnPFolderItem -FolderSiteRelativeUrl "Shared Documents\Test"

0 Replies