Forum Discussion
Reading Sharepoint List Item Values with Powershell gives me a value factor 10 (60 instead of 6)
Hi,
I'm using Powershell & MS-Graph API to read some information from a Sharepoint List.
The Sharepoint List have a Field Object_Capacity (Type : Number (1, 1.0, 100)) where I enter a value.
In the Sharepoint List I see the Correct Value
When Requesting the Sharepoint List item with powershell Command (Get-MgSiteListItem -SiteId $ICTTeamId -ListId $ICTObjectListNameId -ExpandProperty 'fields' -All).Fields.AdditionalProperties.Object_Capacity) I get values 10 times bigger than shown in the sharepoint List.
Ex 6 => 60 , 100 =>1000
Update:
Using Get-PnPListItem gives me the correct value
Using MS Graph Explorer https://graph.microsoft.com/v1.0/sites/<SiteID>/lists/<ListID>/items/<ItemID> gives me the correct value
Anyone any Idea how to fix this ?
Regards
Kurt
- LeonPavesicSilver Contributor
Hi eFrogBE,
For the issue yo are facing, you can use the provided PowerShell script. It essentially fetches the item from Microsoft Graph and then scales down the value by dividing it by 10.
This way, you'll get the correct value that matches what you initially entered in your SharePoint list.# Install the required module if not already installed Install-Module -Name Microsoft.Graph # Connect to Microsoft Graph using your credentials Connect-MgGraph -Scopes "Sites.Read.All", "Lists.Read.All" # Specify your SharePoint site, list, and item IDs $siteId = "<Your-Site-ID>" $listId = "<Your-List-ID>" $itemId = "<Your-Item-ID>" $fieldInternalName = "Object_Capacity" # Replace with your field name # Retrieve the list item without expanding the fields $item = Get-MgSiteListItem -SiteId $siteId -ListId $listId -Id $itemId # Fetch the specific field value using its internal name $objectCapacity = $item.Fields.AdditionalProperties[$fieldInternalName] # Divide the retrieved value by 10 to get the correct value $correctValue = $objectCapacity / 10 # Output the correct value Write-Host "Correct Value: $correctValue"
Just make sure to swap out the placeholders with your own SharePoint site, list, and item details. It should straighten things out and give you the right numbers.
Please click Mark as Best Response & Like if my post helped you to solve your issue.
This will help others to find the correct solution easily. It also closes the item.If the post was useful in other ways, please consider giving it Like.
Kindest regards,
Leon Pavesic
- eFrogBECopper Contributor
LeonPavesic
Thanks for the feedback.
This is indeed the work around I have used in my scripts.
But there is something wrong in the Powershell MSGraph command MgSiteListItem which in my opinion should be solved.
I'll try to figger out where to escalate this to Microsoft Powershell MSGraph development team.kurt
- eFrogBECopper Contributor
Hi,
I found the cause:
It look to a Regional setting Issue.
On my computers the regional setting is:I changed it to this:
In the sharepoint list, when changing the value into 5.6 (dot) it gives me 56 in the Browser
Entering 5,6 comma) gives me 5,6 in the Browser.Conclusing, Issue is caused by Regional setting of the computer running the script.
The Powershell Command Get-MgSiteListItem has a Regional setting issue.
Regards
Kurt