microsoftgraph / msgraph-sdk-powershell

Powershell SDK for Microsoft Graph
https://www.powershellgallery.com/packages/Microsoft.Graph
Other
712 stars 172 forks source link

Get-MgSiteListItem - Not returning all field names but mapping these to field_<nn> #2976

Closed gjhardie closed 1 month ago

gjhardie commented 1 month ago

Describe the bug

I'm trying to retrieve a SharePoint List using: $items = (Get-MgSiteListItem -ListId $listID -SiteId $siteId -ExpandProperty "fields" -All).Fields.AdditionalProperties When we return the keys for the list using: $Items[0].keys This returns: @odata.etag Title field_0 field_2 field_3 field_4 field_5 field_6 field_7 field_9 field_10 field_12 field_14 field_15 field_16 field_19 field_22 field_24 LinkTitle RegulatedSystem LinkTitleNoMenu ContentType Modified Created AuthorLookupId EditorLookupId _UIVersionString Attachments Edit ItemChildCount FolderChildCount _ComplianceFlags _ComplianceTag _ComplianceTagWritten

Expected behavior

Expected to return: IT Service Ref Application Reference Status etc.

How to reproduce

$items = (Get-MgSiteListItem -ListId $listID-SiteId $siteId -ExpandProperty "fields" -All).Fields.AdditionalProperties $Items[0].keys

SDK Version

2.23.0

Latest version known to work for scenario above?

This is first attempt

Known Workarounds

It's possible access the SharePoint List from a browser, to identify which fields fields_ are mapped to.

Debug output

Click to expand log ``` ```

Configuration

Name Value


PSVersion 5.1.22621.4111
PSEdition Desktop
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0...}
BuildVersion 10.0.22621.4111
CLRVersion 4.0.30319.42000
WSManStackVersion 3.0
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1

Other information

No response

kilasuit commented 1 month ago

This is due to how the fields were created IIRC Where they created using the browser by any chance?

SharePoint Client Browser is a good tool that can help you map the auto generated names to the ones you visibly use so can then post return from this cmdlet do object transformations that may already be available using the Pnp.PowerShell module (can't remember been a long time since using it)

That may help you in the meantime

However I agree in that it would be nice for this to return the friendly name for the fields unless not already provided via a switch parameter on this cmdlet

gjhardie commented 1 month ago

@kilasuit Thanks for coming back. I wasn't the original author and only have read access to the list. However, I've found that I can resolve the field names to column names using: Get-MgSiteListColumn -ListId $ListId -SiteId $siteId | Select Name, DisplayName

timayabi2020 commented 1 month ago

@kilasuit, thanks for opening and going ahead to provide a solution for this issue. For any cmdlet result one can always select the properties that are needed through piping. Kindly close this issue if it's no longer a problem. Thanks @kilasuit for suggesting a solution on this issue too :)

microsoft-github-policy-service[bot] commented 1 month ago

This issue has been automatically marked as stale because it has been marked as requiring author feedback but has not had any activity for 4 days. It will be closed if no further activity occurs within 3 days of this comment.