0

I am attempting to upload images to my site assets folder using the Add-PnPFile powershell command. The command executes successfully and I am able to go to the ServerRelativeUrl and see the image, but I am not able to see the images when navigating to the Site Assets folder inside of Sharepoint.

The following is the command I am running:

Connect-PnPOnline -Url https://mysite.sharepoint.com
Add-PnPFile -FileName test.png -Folder "Site Assets" -Stream $stream

Where $stream is a System.IO.MemoryStream that contains the image.

Here is the result of running the command:

Name     Type Items/Size Last Modified      
----     ---- ---------- -------------      
test.png File      33827 7/8/2020 7:47:31 PM

The ServerRelativeUrl returns /Site Assets/test.png, and going to mysite.sharepoint.com/Site Assets/test.png shows the image correctly, but it does not show up in the Site Assets folder in my site. Is there a different folder path I am supposed to use to upload it to the correct folder?

Any help is appreciated, thanks.

0

My sample test script, you may try it.

#region Variables 
$Username = "user@xxx.onmicrosoft.com" 
$Password = "Password" 
$siteURL = "https://xxx.sharepoint.com/sites/modernteamlee"
#endregion Variables

#region Credentials 
[SecureString]$SecurePass = ConvertTo-SecureString $Password -AsPlainText -Force 
[System.Management.Automation.PSCredential]$PSCredentials = New-Object System.Management.Automation.PSCredential($Username, $SecurePass) 
#endregion Credentials

Connect-PnPOnline -Url $siteURL -Credentials $PSCredentials

Add-PnPFile -Path "C:\Lee\panda.jpg" -Folder "SiteAssets" -NewFileName "panda.jpg"
Write-Host "-----------"
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.