Forum Discussion
Reading Sharepoint List Item Values with Powershell gives me a value factor 10 (60 instead of 6)
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
- eFrogBESep 19, 2023Copper 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
- eFrogBESep 25, 2023Copper 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