Apply-SPOProvisioningTemplate or Get-SPOProvisioningTemplate? The issue is most likely related to the Provisioning Engine. The Provisioning engine is _not_ located in the PowerShell repo. Please report the issue here: https://github.com/officedev/PnP-Sites-Core/issues.GEt-PnPListItem returns an error when downloading List Attachments
Expect to see the attachment file name
Get an error
The collection has not been initialized. It has not been requested or the request has not been executed. It may need to be explicitly requested.
At line:1 char:9
Here is the code
Connect-PnpOnline -Url TenantUrl -Credentials (Get-Credential)
$item = Get-PnPListItem -List [ListUrl] -Query "
<Eq>
<FieldRef Name='Title' />
<Value Type='Text'>[ItemTitle]</Value>
</Eq>
</Where></Query></View>"
$AttachColl = $item.AttachmentFiles
foreach($Attach in $AttachColl)
{
Write-Host $Attach.FileName
}
(you can retrieve this by executing Get-Module -Name *pnppowershell* -ListAvailable)
Hi,
you need to request for the AttachmentFiles property to be loaded. Not all properties are loaded by default in CSOM, some of them you have to request manually.
Here's how to do it in your case (changes bold):
$AttachColl = $item.AttachmentFiles
$ctx = Get-PnPContext
$ctx.Load($AttachColl)
$ctx.ExecuteQuery()
foreach($Attach in $AttachColl)
{
Write-Host $Attach.FileName
}
Thanks Rene for answering this. Another approach you can use is
$attachments = Get-PnPProperty -ClientObject $item -Property "AttachmentFiles"
Most helpful comment
Thanks Rene for answering this. Another approach you can use is