Update all items in a list using PowerShell Update all items in a list using PowerShell powershell powershell

Update all items in a list using PowerShell


Assuming the list you want to update is located at http://YouServer/ListLocation/Lists/TheList:

$web = Get-SPWeb http://YourServer/ListLocation$list = $web.Lists["TheList"]foreach ($item in $list.Items){  $item["Number"] = Get-Random -Min 0 -Max 100;  $item.Update();}

You need to execute this code in the SharePoint 2010 Management Shell or add the SharePoint PowerShell snap-in manually:

Add-PSSnapin Microsoft.SharePoint.PowerShell


You may try something like the following:

$list | ForEach-Object { $_.Number = Get-Random -Min 0 -Max 100 }