PowerShell script to upload Excel File into SharePoint List

  1. If((Get - PSSnapin | Where   
  2. {  
  3.     $_.Name - eq "Microsoft.SharePoint.PowerShel"  
  4. }) - eq null) {  
  5.     Add - PSSnapin Microsoft.SharePoint.PowerShel  
  6. }  
  7. $web = Get - SPWeb http: //sharepoint/  
  8. $list = $web.lists("RMD FRSN Data")  
  9. $cnt = 0  
  10. foreach($i in Import - CSV File.csv)#put your file name in place of file.csv   
  11. {  
  12.     $new = $list.Items.Add()  
  13.     $new["EmployeeCode"] = i.EmployeeCode  
  14.     $new["SalesOrganization"] = i.SalesOrganization  
  15.     $new["CreatedAt"] = i.CreatedAt  
  16.     $new.Update()  
  17.     $cnt++  
  18. }  
  19. "Added " + $cnt.ToString() + " records."