msgraph-sdk-powershell icon indicating copy to clipboard operation
msgraph-sdk-powershell copied to clipboard

Getting fields with Get-MgSiteListItem

Open maryha opened this issue 5 years ago • 2 comments

Perhaps I am doing something wrong, but I cannot seem to get any fields other than Id when getting list items from SharePoint. I have a list with custom columns for Category, Description, and TeamLink, but when I run the following command, all I get back in the "fields" set of properties is "Id":

Get-MgSiteListItem -ListId $listId -SiteId $SiteId -ExpandProperty "fields(`$select=Title,Description,ID,Category)"

Get-MgSiteListItem -ListId $listId -SiteId $SiteId -ExpandProperty "fields" also only returns Id in the set of fields

image

AB#10229

maryha avatar Jul 15 '21 12:07 maryha

@maryha This because fields is defined as OpenType in the metadata (it can have any property). You should be able to get the properties in the AdditionalProperties property bag like this:


$items[0].fields.AdditionalProperties

Key                       Value
---                       -----
@odata.etag               "bc724093-7acc-4e3c-82ef-24e422e0aa2a,1"
ContentType               Item
Title                     Item
Modified                  2021-07-15T23:21:59Z
Created                   2021-07-15T23:21:59Z
AuthorLookupId            11
EditorLookupId            11
_UIVersionString          1.0
Attachments               False
Edit
LinkTitleNoMenu           Item
LinkTitle                 Item
ItemChildCount            0
FolderChildCount          0

peombwa avatar Jul 15 '21 23:07 peombwa

Yes, that did work!! Thank you for the response :-). Just need that documented somewhere

maryha avatar Jul 15 '21 23:07 maryha