Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] ListItemAllFields property is empty for Get-PNPFolderItem #4139

Open
5 tasks
sg1888 opened this issue Aug 7, 2024 · 3 comments
Open
5 tasks

[BUG] ListItemAllFields property is empty for Get-PNPFolderItem #4139

sg1888 opened this issue Aug 7, 2024 · 3 comments
Labels
bug Something isn't working

Comments

@sg1888
Copy link

sg1888 commented Aug 7, 2024

Reporting an Issue or Missing Feature

When I am using Get-PNPFolderItem, the items returned do not have ListItemAllFields data. It just shows up as an empty output. Unlike the Get-PnPFolder command, you also can't load the properties using -Includes ListItemAllFields.

Related bugs:
pnp/PnP-PowerShell#2061
#2679

Expected behavior

I would expect to see the Item ID, Title and GUID populated. The Item ID is critical as that is what many PNP commands require to edit / modify files.

Actual behavior

I do not see any properties. The ID, Title, and GUID are empty.
Get-PNPFolderItem

Steps to reproduce behavior

Connect-PnPOnline -url $url -Credentials $Credentials
$Items = Get-PNPFolderItem -FolderSiteRelativeUrl $PathToFolder
$Items[1].ListItemAllFields

What is the version of the Cmdlet module you are running?

2.5.0

Which operating system/environment are you running PnP PowerShell on?

  • [X ] Windows
  • Linux
  • MacOS
  • Azure Cloud Shell
  • Azure Functions
  • Other : please specify
@sg1888 sg1888 added the bug Something isn't working label Aug 7, 2024
@ToddKlindt
Copy link
Contributor

Because we don't know how big each object is, the PnP cmdlets usually just pull a select few properties down for each object. While that's a drag, there is a way to get the other properties. See if using Get-PnPProperty works for you. It would look like this:

$a = Get-PnPFolderItem -FolderSiteRelativeUrl "Documents 2" -Recursive $a | foreach {Get-PnPProperty -ClientObject $_ -Property ListItemAllFields}

Now when you run $a[5].ListItemAllFields it's populated.

I assume you already know about Get-PnPListItem, but I thought I'd mention it just in case.

@sg1888
Copy link
Author

sg1888 commented Aug 7, 2024

Because we don't know how big each object is, the PnP cmdlets usually just pull a select few properties down for each object. While that's a drag, there is a way to get the other properties. See if using Get-PnPProperty works for you. It would look like this:

$a = Get-PnPFolderItem -FolderSiteRelativeUrl "Documents 2" -Recursive $a | foreach {Get-PnPProperty -ClientObject $_ -Property ListItemAllFields}

Now when you run $a[5].ListItemAllFields it's populated.

I assume you already know about Get-PnPListItem, but I thought I'd mention it just in case.

Thank you for the suggestion! The Get-PnPProperty does indeed work, but it is slow - I have 4 million files to process, so all those milliseconds adds up. I'm not too familiar with the inner workings of PnP cmldlets, but was hoping that the ID would be included as it's required for so many other cmdlets (such as Set-PnPListItem, etc).

I'm familiar with Get-PnPListItem, but I haven't found a way to limit what it loads. I tried using the -FolderServerRelativeURL using the line below:

Get-PnPListItem -list "Documents" -FolderServerRelativeURL "/sites/somerelativeurl" -PageSize 10000

But whenever I do, it ignores the PageSize and the operation fails since it exceeds the list view threshold. Is there a better way to use Get-PnPListItem to isolate only certain folders on a large list?

@ToddKlindt
Copy link
Contributor

I think CAML might be the way you need to go. Look at Get-PnPListItem examples #5 and #6 for an idea what that looks like. I had ChatGPT throw together a couple of things for me but I couldn't get it to work the way you want. I'm not a CAML expert though. You might have better luck.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants