Skip to main content
Added the working solution code - derived from provided answers
Source Link
Jesus Shelby
  • 10.9k
  • 25
  • 52

I have data from a CSV that will be imported and added to column values for each of these items. I can loop over CSV, get the items, and set the values (Set-PNPListItem) - but the sequential operations take quite way too long.

Google-fu may be weak on this subject as I'm not finding much info, and I can't imagine this isn't an issue for others.

Is there a way to batch or queue up requests with the PNP CMDLETS? If not how are those of you that are doing it handling this?

Edit


I ended up getting CSOM library to work directly. This was what I ended up with - and it worked, so I'm good to go!

 $lastItemID = 0
    $counter = 0
    $csv = import-csv .\Downloads\slabtarget.csv | Sort-Object Id 
    foreach($item in $csv){
        if([Int32]($item.id) -le $lastItemID){
            Continue;
        }else{
            $listItem = $list.GetItemById($item.id)
    
            $listItem["Gallery"] = $item.Gallery
            $listItem["Branch"] = $item.Branch
            $listItem["Image"] = $item.Image
            $listItem["Product_Type"] = $item.Product_Type
            $listItem["Collection"] = $item.Collection
    
            $listItem.update()
            $lastItemID = $item.Id
            $counter ++
        }
    
        if($counter -eq 100){
            $context.ExecuteQueryAsync()
            $counter = 0
        }
    }

I have data from a CSV that will be imported and added to column values for each of these items. I can loop over CSV, get the items, and set the values (Set-PNPListItem) - but the sequential operations take quite way too long.

Google-fu may be weak on this subject as I'm not finding much info, and I can't imagine this isn't an issue for others.

Is there a way to batch or queue up requests with the PNP CMDLETS? If not how are those of you that are doing it handling this?

I have data from a CSV that will be imported and added to column values for each of these items. I can loop over CSV, get the items, and set the values (Set-PNPListItem) - but the sequential operations take quite way too long.

Google-fu may be weak on this subject as I'm not finding much info, and I can't imagine this isn't an issue for others.

Is there a way to batch or queue up requests with the PNP CMDLETS? If not how are those of you that are doing it handling this?

Edit


I ended up getting CSOM library to work directly. This was what I ended up with - and it worked, so I'm good to go!

 $lastItemID = 0
    $counter = 0
    $csv = import-csv .\Downloads\slabtarget.csv | Sort-Object Id 
    foreach($item in $csv){
        if([Int32]($item.id) -le $lastItemID){
            Continue;
        }else{
            $listItem = $list.GetItemById($item.id)
    
            $listItem["Gallery"] = $item.Gallery
            $listItem["Branch"] = $item.Branch
            $listItem["Image"] = $item.Image
            $listItem["Product_Type"] = $item.Product_Type
            $listItem["Collection"] = $item.Collection
    
            $listItem.update()
            $lastItemID = $item.Id
            $counter ++
        }
    
        if($counter -eq 100){
            $context.ExecuteQueryAsync()
            $counter = 0
        }
    }
Notice removed Draw attention by Jesus Shelby
Bounty Ended with Siddharth Vaghasia's answer chosen by Jesus Shelby
Tweeted twitter.com/StackSharePoint/status/1140771303718305797
Notice added Draw attention by Jesus Shelby
Bounty Started worth 300 reputation by Jesus Shelby
Source Link
Jesus Shelby
  • 10.9k
  • 25
  • 52

Batch update via PNP Powershell

I have data from a CSV that will be imported and added to column values for each of these items. I can loop over CSV, get the items, and set the values (Set-PNPListItem) - but the sequential operations take quite way too long.

Google-fu may be weak on this subject as I'm not finding much info, and I can't imagine this isn't an issue for others.

Is there a way to batch or queue up requests with the PNP CMDLETS? If not how are those of you that are doing it handling this?