Get-PnPFile Fails When Called From Azure Runbook #2593
Unanswered
dremillard
asked this question in
Q&A
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Discussed in #2585
Originally posted by dremillard November 28, 2022
Hi folks,
I'm trying to download a file from SharePoint Online using Get-PnPFile. I'm using an Azure App Registration and Cert Thumbprint to connect. It works fine when I do it from my laptop but fails with a "file not found 404" when I do it from a PowerShell runbook in Azure.
I'm running PowerShell 7 and PnP.PowerShell version 1.12. (Other things break if I use PowerShell 5).
Connect statement is like:
$Conn = Connect-PnPOnline -Url $SiteURL -ClientId $ClientID -Tenant $TenantID -Thumbprint $Thumbprint -ReturnConnection
Get-PnPFile statement is like:
Get-PnPFile -Url $SiteTemplateURL -Path c:\temp -FileName $SiteTemplateFile -AsFile -Connection $Conn
From examples I've seen online, $SiteTemplateURL seems to need a server relative address like "/sites/sitename/libraryname/documentname.xml". I've also tried just "/libraryname/documentname.xml" to no avail.
I've also tried putting a variable in front like:
$status = Get-PnPFile -Url $SiteTemplateURL -Path c:\temp -FileName $SiteTemplateFile -AsFile -Connection $Conn
I've also tried something I found in a Tony Redmond article:
$status = (Get-PnPFile -Url $SiteTemplateURL -Path c:\temp -FileName $SiteTemplateFile -AsFile -Connection $Conn | Out-Null)
Any ideas on why it would work on my laptop but not in an Azure Runbook? Anyone bump into this before?
Thanks in advance,
Dave
Beta Was this translation helpful? Give feedback.
All reactions