SharePoint on Prem - Update List

Iron Contributor

Hello
I am running a Powershell to update a list.


While running this powershell with my user account the columns are updated.

While running this powershell through taks-scheduler (other user) the data within the columns are dropped but

not updated. The user from task-scheduler is owner of the specific list.

 

What could be the reason.

 

Thank you

J.

2 Replies
Hi,
Try to use try-catch block within the PowerShell to capture for any issues. If there is no issue, then the fields are skipped because of the permission, make sure the scheduler run on-behalf of the user who has permission to update the fields.

@Sudharsan K 

Hello
Thank you for your input.

I did already run try-catch and no errors

The task-Scheduler runs with an technical user with highest privileges.

The funny Thing user drops the data within the column but does not inserts the data.

 

Here the sample:

$items = $list.Items

    foreach($item in $items)
    {        
        $owner = $item['Besitzer']
        $ownertest = $owner -replace ".*#"
        $costcentercsv = $CSVData | Where-Object {$_.UsEMail -eq $ownertest} | % UsAccountNum
        $item[$costcenter] = $costcentercsv
        $item.Update();
        
     }
    }
   
   Catch
   {
     $logger.LogError("Exception raised")
     $logger.LogException($_.Exception)
     $script:sitesErrors = $script:sitesErrors + 1
     $script:scriptError = $true
   }

 

Regards