I wrote a script to add files to a document library within SharePoint. Pretty straightforward, however I now want to add that same file to a different document library depending on if certain criteria is met. Something like:
if ($Value -eq "DocumentLibrary1") {
Add-PnPFile -Path $Path -Folder "DocumentLibrary1" -Values $HashTable
Write-Host "PAUSE-------POLICY-----------------------" - ForegroundColor red -BackgroundColor white
Add-PnPFile -Path $Path -Folder "DocumentLibrary2" -Values $HashTable
}
else {
Add-PnPFile -Path $Path -Folder "DocumentLibrary3" - Values $HashTable
}
However this does not work for some reason and only add to the one document library (Document LIbrary 1 in my example) and skips over the rest. It doesn't even do the "Write" command i have immediately after even though the document gets added. Why is that?