Within a SharePoint Online list I am attempting to update a column based on another column, all within the same list.

List - TestUpdate

Source Column - Created

Destination Column - Scan Date

I have attempted the following but get PowerShell error that Cannot index into a null array. This suggests I am not correctly collecting the site name?

$listName = "TestUpdate"

$web = Get-SPOSite -Identity "https://domain.sharepoint.com/sites/sitename"

$list = $web.Lists[$listName]

$items = $list.items

foreach($item in $items)

    $user = $item["Created"]

    $item["Scan_x0020_Date"] = $user



I value your opinions. Thanks in advance.


You cannot do it by using the SharePoint Online PowerShell directly, that is mainly for maintenance tasks.

Luckily we have the PnP PowerShell Library that makes these kinds of operations quite easy:

Connect-PnPOnline -Url "https://domain.sharepoint.com/sites/sitename" -Credentials (Get-Credential)
$listname = "TestUpdate"
$items = Get-PnPListItem -List $listname

foreach ($item in $items) {
  Set-PnPListItem -List $listname -Identity $item.Id -Values @{"Scan_x0020_Date"=$item["Created"]}

  • 1
    Outstanding. Saved me a LOT of time @Rune-Sperre Thank you! Mar 13 '20 at 15:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.