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

%3CLINGO-SUB%20id%3D%22lingo-sub-729471%22%20slang%3D%22en-US%22%3EAdd-PnPFile%20%3A%20Access%20denied.%20You%20do%20not%20have%20permission%20to%20perform%20this%20action%20or%20access%20this%20resour%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-729471%22%20slang%3D%22en-US%22%3E%3CDIV%20class%3D%22votecell%20post-layout--left%22%3E%3CDIV%20class%3D%22js-voting-container%20grid%20fd-column%20ai-stretch%20gs4%20fc-black-200%22%3E%3CSPAN%3EI%20am%20trying%20to%20upload%20a%20file%20(actually%20copy%20a%20file%20from%20a%20local%20machine)%20to%20folder%20in%20OneDrive%20for%20Business%3C%2FSPAN%3E%3C%2FDIV%3E%3CDIV%20class%3D%22js-voting-container%20grid%20fd-column%20ai-stretch%20gs4%20fc-black-200%22%3E%26nbsp%3B%3C%2FDIV%3E%3C%2FDIV%3E%3CP%3E%3CSPAN%3E%24UserName%3C%2FSPAN%3E%3CSPAN%3E%3D%3C%2FSPAN%3E%3CSPAN%3E%22user%40domain%22%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%3CSPAN%3E%24pwd%3C%2FSPAN%3E%20%3CSPAN%3E%3D%3C%2FSPAN%3E%3CSPAN%3E%22StrongPassword%22%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%3CSPAN%3E%24SiteUrl%3C%2FSPAN%3E%3CSPAN%3E%3D%3C%2FSPAN%3E%3CSPAN%3E%22%3CA%20href%3D%22https%3A%2F%2Fdomaincorp.sharepoint.com%2Fsites%2Ftesting%22%20target%3D%22_blank%22%20rel%3D%22noopener%20nofollow%20noreferrer%22%3Ehttps%3A%2F%2Fdomaincorp.sharepoint.com%2Fsites%2Ftesting%3C%2FA%3E%22%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%3CSPAN%3E%24encpassword%3C%2FSPAN%3E%20%3CSPAN%3E%3D%3C%2FSPAN%3E%20%3CSPAN%3Econvertto-securestring%3C%2FSPAN%3E%20%3CSPAN%3E-%3C%2FSPAN%3E%3CSPAN%3EString%20%3C%2FSPAN%3E%3CSPAN%3E%24pwd%3C%2FSPAN%3E%20%3CSPAN%3E-%3C%2FSPAN%3E%3CSPAN%3EAsPlainText%20%3C%2FSPAN%3E%3CSPAN%3E-%3C%2FSPAN%3E%3CSPAN%3EForce%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%3CSPAN%3E%24cred%3C%2FSPAN%3E%20%3CSPAN%3E%3D%3C%2FSPAN%3E%20%3CSPAN%3Enew-object%3C%2FSPAN%3E%20%3CSPAN%3E-%3C%2FSPAN%3E%3CSPAN%3Etypename%20System.Management.Automation.PSCredential%20%3C%2FSPAN%3E%3CSPAN%3E-%3C%2FSPAN%3E%3CSPAN%3Eargumentlist%20%3C%2FSPAN%3E%3CSPAN%3E%24username%3C%2FSPAN%3E%3CSPAN%3E%2C%3C%2FSPAN%3E%20%3CSPAN%3E%24encpassword%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%3CSPAN%3EConnect-PnPOnline%3C%2FSPAN%3E%20%3CSPAN%3E-%3C%2FSPAN%3E%3CSPAN%3EUrl%20%3C%2FSPAN%3E%3CSPAN%3E%24SiteUrl%3C%2FSPAN%3E%20%3CSPAN%3E-%3C%2FSPAN%3E%3CSPAN%3ECredentials%20%3C%2FSPAN%3E%3CSPAN%3E%24cred%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%3CSPAN%3Eecho%20%3C%2FSPAN%3E%3CSPAN%3E%22connected%22%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%3CSPAN%3EAdd-PnPFile%3C%2FSPAN%3E%20%3CSPAN%3E-%3C%2FSPAN%3E%3CSPAN%3EPath%20%3C%2FSPAN%3E%3CSPAN%3E'.%5ClocalFileName.docx'%3C%2FSPAN%3E%20%3CSPAN%3E-%3C%2FSPAN%3E%3CSPAN%3EFolder%20%3C%2FSPAN%3E%3CSPAN%3E'Documents'%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CDIV%20class%3D%22votecell%20post-layout--left%22%3E%3CDIV%20class%3D%22js-voting-container%20grid%20fd-column%20ai-stretch%20gs4%20fc-black-200%22%3E%3CDIV%3E%3CDIV%3E%3CSPAN%3EI%20get%20%3A%26nbsp%3BAdd-PnPFile%20%3A%20Access%20denied.%20You%20do%20not%20have%20permission%20to%20perform%20this%20action%20or%20access%20this%20resource.%3C%2FSPAN%3E%3C%2FDIV%3E%3CDIV%3E%26nbsp%3B%3C%2FDIV%3E%3CDIV%3E%3CSPAN%3EI'am%20global%20admin%20in%20O365%20and%20in%20Azure%20Portal%3C%2FSPAN%3E%3C%2FDIV%3E%3C%2FDIV%3E%3C%2FDIV%3E%3C%2FDIV%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-729471%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EPnP%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3ESharePoint%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E
Occasional Contributor
I am trying to upload a file (actually copy a file from a local machine) to folder in OneDrive for Business
 

$UserName="user@domain"

$pwd ="StrongPassword"

$SiteUrl = "https://domaincorp.sharepoint.com/sites/testing"

$encpassword = convertto-securestring -String $pwd -AsPlainText -Force

$cred = new-object -typename System.Management.Automation.PSCredential -argumentlist $username, $encpassword

Connect-PnPOnline -Url $SiteUrl -Credentials $cred

echo "connected"

Add-PnPFile -Path '.\localFileName.docx' -Folder 'Documents'

 

I get : Add-PnPFile : Access denied. You do not have permission to perform this action or access this resource.
 
I'am global admin in O365 and in Azure Portal
0 Replies