Oct 21 2022 01:21 PM - edited Oct 22 2022 08:00 AM
Hello,
I have a request for 2 SharePoint 2013 OnPrem list where they are needing 1,000 records in both lists to simply have the status updated to completed and comment added for specific records. Of course, this would take a lot of hours to manually touch 2,000 records. I've tried to put together a script that will use ID field and then update the status and comment field but no luck with the test. Can someone possibly tell me what I might be missing? Am I using incorrect field names in the script for the default ID? Thanks a ton for any help.
Add-PSSnapin Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue
#Variables
$SiteURL = "http://siteaddress/"
$ListName = "vr"
#Get the List
$List = (Get-SPWeb $SiteURL).Lists.TryGetList($ListName)
#List of Item IDs to update
$ItemIDs = 17148, 17147
If($list)
{
foreach($ItemID in $ItemIDs)
{
#Get Item by ID
$ListItem = $List.GetItembyID($ItemID)
#Update List Item Fields
$ListItem["Status"]="Completed"
$ListItem["Request Comment"]="Completed 10-21-2022"
$ListItem.SystemUpdate()
Write-host "Updated Item ID:"$ItemID
}
}
Oct 22 2022 05:06 AM
@dklbwf you could do this with a simple flow in Power Automate. With 1000 records in each list it woul take a short while to run but is probably a more simple solution.
Rob
Los Gallardos
Microsoft Power Automate Community Super User
Oct 22 2022 07:24 AM
Oct 23 2022 07:50 AM
Is it all items in those SharePoint list?
in case you can use this:
$web = Get-SPWeb https://yoursite #Get the List $List = $web.Lists["YourList"] #Get All Items in the list $ListItems = $List.items #Iterate through each item foreach($Item in $ListItems) { #Update the value of your "YourField" $item["YourField"] = "Hello!" #Update the item $item.Update() }
Oct 23 2022 09:12 AM
Oct 23 2022 09:20 AM - edited Oct 23 2022 09:23 AM
Solution
Oct 24 2022 05:25 AM
@NicolasKheirallah This is the error I am seeing when I run the script
Oct 24 2022 11:03 AM
Oct 24 2022 11:31 AM
@NicolasKheirallah Thanks for the quick response! After updating it is saying it can't find item even though the ID im using is there. I've tried several different ID's but same error. Thanks again
Oct 24 2022 11:51 AM
Oct 24 2022 11:57 AM
Oct 24 2022 11:59 AM
Oct 24 2022 12:03 PM
Oct 24 2022 12:05 PM
Oct 24 2022 12:26 PM
Oct 26 2022 01:41 AM
@dklbwf Are there any item level permissions applied on list items? Make sure user account you are using to run PowerShell has at least Contribute/Edit access to read and update items in SharePoint list.
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.
Oct 26 2022 05:26 AM
Oct 26 2022 05:26 AM
Oct 26 2022 05:33 AM
Oct 23 2022 09:20 AM - edited Oct 23 2022 09:23 AM
Solution