[SPO/PNP] Bulk create a certain number of DOCX files in a document library
So, besides PnP, you will need to have a file called WordDummy.docx in the c:\temp folder. Then, just run the script (and adapt it to your URLs):
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
#Parameters $SiteURL = "https://tenant.sharepoint.com/sites/MP3TEST" $LibraryName = "BULK" $LocalFile= "C:\temp\WordDummy.docx" $MaxFilesCount = 500 Try { #Get the File $File = Get-ChildItem $LocalFile #Connect to PnP Online Connect-PnPOnline -Url $SiteURL -Interactive #$Library = Get-PnPList -Identity $LibraryName $FileCounter = 1 While($FileCounter -le $MaxFilesCount) { $NewFileName= $File.BaseName+"_"+$FileCounter+".docx" Try { Add-PnPFile -Path $File -Folder $LibraryName -NewFileName $NewFileName | Out-Null } Catch { Write-host "Error: $($_.Exception.Message)" -foregroundcolor Red } Write-host -f Green "New File '$NewFileName' Created ($FileCounter of $MaxFilesCount)!" $FileCounter++ } } Catch { write-host -f Red "Error Uploading File:"$_.Exception.Message } |
The […]