pnp/PnP

Unable to add multiple folders to a library in a Runbook

oysterhoys opened this issue · 2 comments

PnP.Powershell 1.2.0

Category

[X ] Bug

Environment

[ X] Azure Automation
[ X ] Office 365 / SharePoint Online

Expected or Desired Behavior

Adding multiple folders with Add-PnPFolder to a library

Observed Behavior

Runbook runs very slow and gets Suspended finally.
Max. 3 folders created
Looking at the error messages, it seems that somehow it even goes into a loop of repeating commands.

Steps to Reproduce

Code used:

$dcSharePointRootUrl = "https://XXXX.sharepoint.com/sites/"
$SiteUrl = "13Test"
$credential = Get-AutomationPSCredential -Name "XXX" ;
$targetSite = $dcSharePointRootUrl + $SiteUrl
Connect-PnPOnline -Url $targetSite -Credentials $credential
$targetFolder = "/sites/"+ $SiteUrl + "/Shared Documents"
Add-PnPFolder -Name "Technical proposal" -Folder $targetFolder
Add-PnPFolder -Name "Procurement" -Folder $targetFolder
Add-PnPFolder -Name "Engineering" -Folder $targetFolder
Add-PnPFolder -Name "Commercial proposal" -Folder $targetFolder

Error messages: Add-PnPFolder : A file or folder with the name https://xxxx.sharepoint.com/sites/13Test/Shared Documents/Technical proposal already exists. At line:16 char:1 + Add-PnPFolder -Name "Technical proposal" -Folder $targetFolder +

Maybe i should have posted it @microsoft is it related to the PowerShell version online

fixed it myself .
A runbooks needs a variable for a command:
$dummy = Add-PnPFolder -Name "Technical proposal" -Folder $targetFolder