Question

Param
(
 [Parameter (Mandatory= $true)]
 [string] $siteUrl,
 [Parameter (Mandatory= $true)]
 [string] $DocLibName
)


#Connect to SPO
$tenantName= "client"
$username = "admin@client.onmicrosoft.com"
$password = "hashing!" | ConvertTo-SecureString -AsPlainText -Force
$cred = New-Object System.Management.Automation.PSCredential -ArgumentList $Username,$Password


#create view
$ViewName= "Grouped by Team"
$ViewFields = @("DocIcon","LinkFilename","Team", "Modified", "Modified_x0020_By")
$ViewQuery = "<GroupBy Collapse=""TRUE""><FieldRef Name=""Team"" Ascending=""True""/></GroupBy> <OrderBy><FieldRef Name=""LinkFilename"" /></OrderBy>"

#provide view
Connect-PnPOnline -Url $siteUrl -Credentials $cred
Add-PnPView -List $DocLibName -Title $ViewName -Fields $ViewFields -Query $ViewQuery

I'm running this Runbooks/PowerShell script. Somehow this script always runs 3 times in Azure with an exception:

The runbook job was attempted 3 times, but it failed each time. Common reasons that runbook jobs fail can be found here: https://docs.microsoft.com/en-us/azure/automation/automation-troubleshooting-automation-errors

The script works like a charm on my local PowerShell and PowerShell ISE...

Any runbooks hero in the house?

No correct solution

OTHER TIPS

I had same issue when executing Add-PnPListItem and Add-PnPFile on Azure Runbook. I googled answers and finally found the following threads:

https://github.com/SharePoint/PnP-PowerShell/issues/1541

https://github.com/SharePoint/PnP-PowerShell/issues/918

They suggest a workaround for this issue is assigning output to a variable like below.

$dummy = Add-PnpFile -Path $file -Folder $folder

It works for me. Your issue seems same kind, so it is worth trying. Hope it will help!

Licensed under: CC-BY-SA with attribution
Not affiliated with sharepoint.stackexchange
scroll top