admin管理员组文章数量:1404571
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?
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?
Share Improve this question edited Mar 10 at 15:38 Mathias R. Jessen 176k13 gold badges172 silver badges230 bronze badges asked Mar 10 at 15:28 DanielJDanielJ 1091 gold badge4 silver badges14 bronze badges 3- The behavior you describe could indicate that you're not actually running the latest version of your script - how are you executing the code? – Mathias R. Jessen Commented Mar 10 at 15:39
- I'm copy and pasting the whole script into the terminal – DanielJ Commented Mar 10 at 15:46
- Are you getting an exception? – jdweng Commented Mar 10 at 16:29
1 Answer
Reset to default 0Apparantly i've been hitting the else this whole time and not the If. Should've added a write host to the Else. Thank you all for your help
本文标签:
版权声明:本文标题:sharepoint - Powershell script using Add-PnPFile to add same file to 2 different libraries isn't working - Stack Overflo 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744838110a2627756.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论