首页 > 解决方案 > 使用大块通过 PNP-Powershell 递归地将大文件上传到 Sharepoint Online

问题描述

我有一些文件需要与我的 SharePoint 文档库保持同步。问题是一些文件超过了 250mb 的限制,我目前拥有的代码可以工作,但仅适用于低于 250mb 限制的文件。我不知道如何使用相同的代码和大块将我需要的相同递归文件上传到 SharePoint?看来我需要集成的是此页面的选项 3 -> 大文件处理 - 选项 3(StartUpload、ContinueUpload 和 FinishUpload) ,如果文件存在以跳过并继续前进,似乎也if (Test-Path($topSPOFolder+"\"+$aFileName.FullName))没有检查目标目录。任何帮助总是受到赞赏。

$password = ConvertTo-SecureString "test123" -AsPlainText -Force
$username = "abc@def.com"
$cred = New-Object System.Management.Automation.PSCredential ($username, $password)
$makeUrl ="https://helloworld.sharepoint.com/sites/helloworld"
$sourcePath = "\\1.2.3.4\e$\MSI\packages\*\*.msi";
$topSPOFolder = "Shared Documents\packages\test";
# install pnp powershell..?
#Install-Module SharePointPnPPowerShellOnline
# connect to spo online
Connect-PnPOnline -Url $makeUrl -Credentials $cred
$fileNames = Get-ChildItem -Path $sourcePath -Recurse ;
foreach($aFileName in $fileNames)
{
if($aFileName.GetType().Name -ne "DirectoryInfo") 
   {
    if (Test-Path($topSPOFolder+"\"+$aFileName.FullName)) 
    {
        Write-Host 'Skipping file, already downloaded' -ForegroundColor Yellow
        return
    } else {
      $fn=$topSPOFolder;
      Add-PnPFile -Path $aFileName.FullName -Folder $fn;
      $fn=$null
    }
   }
}

标签: powershellsharepoint

解决方案


推荐阅读