{"action":"created","issue":{"url":"https://api.github.com/repos/SharePoint/PnP-PowerShell/issues/592","repository_url":"https://api.github.com/repos/SharePoint/PnP-PowerShell","labels_url":"https://api.github.com/repos/SharePoint/PnP-PowerShell/issues/592/labels{/name}","comments_url":"https://api.github.com/repos/SharePoint/PnP-PowerShell/issues/592/comments","events_url":"https://api.github.com/repos/SharePoint/PnP-PowerShell/issues/592/events","html_url":"https://github.com/SharePoint/PnP-PowerShell/issues/592","id":193649162,"number":592,"title":"Get-PnpListItem errors when downloading list item attachment","user":{"login":"bkirti","id":24399494,"avatar_url":"https://avatars.githubusercontent.com/u/24399494?v=3","gravatar_id":"","url":"https://api.github.com/users/bkirti","html_url":"https://github.com/bkirti","followers_url":"https://api.github.com/users/bkirti/followers","following_url":"https://api.github.com/users/bkirti/following{/other_user}","gists_url":"https://api.github.com/users/bkirti/gists{/gist_id}","starred_url":"https://api.github.com/users/bkirti/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bkirti/subscriptions","organizations_url":"https://api.github.com/users/bkirti/orgs","repos_url":"https://api.github.com/users/bkirti/repos","events_url":"https://api.github.com/users/bkirti/events{/privacy}","received_events_url":"https://api.github.com/users/bkirti/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":1,"created_at":"2016-12-06T00:18:51Z","updated_at":"2016-12-15T10:03:56Z","closed_at":null,"body":"###Notice: many issues / bugs reported are actually related to the PnP Core Library which is used behind the scenes. Consider carefully where to report an issue:###\r\n\r\n1. **Are you using ```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.\r\n2. **Is the issue related to the cmdlet itself, its parameters, the syntax, or do you suspect it is the code of the cmdlet that is causing the issue?** Then please continue reporting the issue in this repo.\r\n3. **If you think that the functionality might be related to the underlying libraries that the cmdlet is calling** (We realize that that might be difficult to determine), please first double check the code of the cmdlet, which can be found here: https://github.com/OfficeDev/PnP-PowerShell/tree/master/Commands. If related to the cmdlet, continue reporting the issue here, otherwise report the issue at https://github.com/officedev/PnP-Sites-Core/issues\r\n\r\n### Reporting an Issue or Missing Feature\r\nGEt-PnPListItem returns an error when downloading List Attachments\r\n\r\n### Expected behavior \r\nExpect to see the attachment file name\r\n\r\n### Actual behavior \r\nGet an error\r\nThe collection has not been initialized. It has not been requested or the request has not been executed. It may need to be explicitly requested.\r\nAt line:1 char:9\r\n+ foreach($Attach in $AttachColl)\r\n+         ~~~~~~~\r\n    + CategoryInfo          : OperationStopped: (:) [], CollectionNotInitializedException\r\n    + FullyQualifiedErrorId : Microsoft.SharePoint.Client.CollectionNotInitializedException\r\n\r\n### Steps to reproduce behavior\r\nHere is the code\r\nConnect-PnpOnline -Url TenantUrl -Credentials (Get-Credential)\r\n $item = Get-PnPListItem -List [ListUrl] -Query \"<View><Query>   <Where> \r\n                \r\n                    <Eq>\r\n                        <FieldRef Name='Title' /> \r\n                        <Value Type='Text'>[ItemTitle]</Value> \r\n                    </Eq> \r\n                \r\n                </Where></Query></View>\"\r\n                \r\n \r\n \r\n \r\n$AttachColl = $item.AttachmentFiles\r\n\r\n\r\nforeach($Attach in $AttachColl)\r\n{\r\n    Write-Host $Attach.FileName\r\n}\r\n\r\n\r\n\r\n### Which version of the PnP-PowerShell Cmdlets are you using?\r\n\r\n- [ ] PnP PowerShell for SharePoint Online\r\n\r\n### What is the version of the Cmdlet module you are running?\r\n(you can retrieve this by executing ```Get-Module -Name *pnppowershell* -ListAvailable```)\r\n\r\n### How did you install the PnP-PowerShell Cmdlets? \r\n- [ ] MSI Installed downloaded from GitHub\r\n\r\n\r\n"},"comment":{"url":"https://api.github.com/repos/SharePoint/PnP-PowerShell/issues/comments/267288713","html_url":"https://github.com/SharePoint/PnP-PowerShell/issues/592#issuecomment-267288713","issue_url":"https://api.github.com/repos/SharePoint/PnP-PowerShell/issues/592","id":267288713,"user":{"login":"modery","id":15896715,"avatar_url":"https://avatars.githubusercontent.com/u/15896715?v=3","gravatar_id":"","url":"https://api.github.com/users/modery","html_url":"https://github.com/modery","followers_url":"https://api.github.com/users/modery/followers","following_url":"https://api.github.com/users/modery/following{/other_user}","gists_url":"https://api.github.com/users/modery/gists{/gist_id}","starred_url":"https://api.github.com/users/modery/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/modery/subscriptions","organizations_url":"https://api.github.com/users/modery/orgs","repos_url":"https://api.github.com/users/modery/repos","events_url":"https://api.github.com/users/modery/events{/privacy}","received_events_url":"https://api.github.com/users/modery/received_events","type":"User","site_admin":false},"created_at":"2016-12-15T10:03:56Z","updated_at":"2016-12-15T10:03:56Z","body":"Hi,\r\n\r\nyou 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.\r\n\r\nHere's how to do it in your case (changes **bold**):\r\n\r\n$AttachColl = $item.AttachmentFiles\r\n**$ctx = Get-PnPContext\r\n$ctx.Load($AttachColl)\r\n$ctx.ExecuteQuery()**\r\nforeach($Attach in $AttachColl)\r\n{\r\nWrite-Host $Attach.FileName\r\n}"}}
{"actor":{"display_login":"modery"}}