question

YUANGaby-3590 avatar image
0 Votes"
YUANGaby-3590 asked EchoDu-MSFT commented

Issues with sending files from local server to sharepoint online

Hi,

We use sharepointpnppowershellonline to send files from local server to sharepoint online.

We first "Connect-PnPOnline -Url" then user for each and send the files with "Add-PnPFile -Folder $FolderPath -Path $File.FullName -Values ".

The same script was running ok but this month it failed. It failed to connect. Tried again the next day, it worked again.

I wonder whether there is anything we can do to avoid this from happening again.

Regards
Gaby

office-sharepoint-online
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

EchoDu-MSFT avatar image
1 Vote"
EchoDu-MSFT answered EchoDu-MSFT commented

Hello @YUANGaby-3590 ,

Welcome to Q&A Forum!

We recommended that you use the following code to connect to PNP Online

 Connect-PnPOnline -Url $SiteURL -Credentials (Get-Credential)  

For Example:

 $SiteURL = "https://crescenttech.sharepoint.com/sites/name"
 $SourceFilePath ="C:\Documents\Word-Template.docx"
 #Relative Path of the Library
 $DestinationPath = "https://crescenttech.sharepoint.com/sites/name/Shared Documents" 
 #Connect to PNP Online
 Connect-PnPOnline -Url $SiteURL -Credentials (Get-Credential)  
 #powershell pnp to upload file to sharepoint online
 Add-PnPFile -Path $SourceFilePath -Folder $DestinationPath

96175-1.png

Thanks,
Echo Du

========================== Updated Answer ===========================

Hi @YUANGaby-3590 ,

If you encounter timeout error, it is recommended that you run the following command to disconnect PnP Online

 Disconnect-PnPOnline
 #This will clear out all active tokens

Then re-bulild PnP Online connection and test again.

For more information, please refer to this post.

Thanks,
Echo Du
=======================
If an Answer is helpful, please click "Accept Answer" and upvote it.
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.




1.png (52.7 KiB)
· 5
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Thanks I will give it a try and come back to let you know if that happens again.

Regards
Gaby

0 Votes 0 ·

Hi @YUANGaby-3590 ,

I am looking forward to the good news that your problem is resolved.

Have a nice day! : )

Thanks,
Echo Du

0 Votes 0 ·

Hi @YUANGaby-3590 ,

Would you tell me whether your issue has been resolved or have any update?
I am looking forward to your reply.

Have a nice day!

Thanks,
Echo Du

0 Votes 0 ·

Hi,

Happy to say it is resolved till the next time the error comes again. We run the process on a monthly basis and the error only come up once in the 4 months we have run the process.

Regards
Gaby

0 Votes 0 ·

Hi @YUANGaby-3590 ,

I'm glad to hear that your problem has been solved. : )

If the answer is helpful to you, you can accept it as answer. The behavior will help others who meet the similar issue in the future quickly find the correct answer.

Thanks,
Echo Du

0 Votes 0 ·
YUANGaby-3590 avatar image
0 Votes"
YUANGaby-3590 answered EchoDu-MSFT commented

Hi,

Our code pretty much same as yours but my question is more on how to avoid the connection failure that happened occasionally.

Regards
Gaby

· 1
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Hi @YUANGaby-3590 ,

Can you tell me the details of the issue you faced? If you can, please attach screenshots.

This can help us better solve the problem.

Have a nice day!

Thanks,
Echo Du

0 Votes 0 ·
YUANGaby-3590 avatar image
0 Votes"
YUANGaby-3590 answered EchoDu-MSFT commented

Hi,

The execution "Connect-PnPOnline -Url $SiteURL -Credentials (Get-Credential) " occasionally will time out.

But if we run it again a few hours later, it will be working fine.

That is basically the issue.

Regards
Gaby

· 1
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Hi @YUANGaby-3590 ,

I have updated answer under initial My Answer. Hope this can help you to solve issue.

Thanks,
Echo Du
=======================
You can directly click “Comment” option under “My Answered” to put forward your opinions and thoughts about solution that I propose.

0 Votes 0 ·