Forum Discussion

JFM_12's avatar
JFM_12
Iron Contributor
Apr 03, 2020

SharePoint on Prem - Update List

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.

  • Sudharsan K's avatar
    Sudharsan K
    Steel Contributor
    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.
    • JFM_12's avatar
      JFM_12
      Iron Contributor

      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

       

Resources