SharePoint, Office 365, Azure, and Front end JS geek. – Chicago IL
SharePoint, Office 365, Azure, and Front end JS geek. – Chicago IL

PowerShell – upload CSV file to List (both Server and Client OM)

Recently I had a friend ask about how to upload a local CSV data file to a SharePoint site.  The scenario is that a daily CSV file is provided on a network share and needs to be imported to SharePoint for viewing, filtering, and sorting.  The easiest way to code this was with Server Side Object Model.  Be sure to compare the source/destination columns and make sure everything lines up OK.   The schema must match for any import to be successful.

This also can be accomplished with Client Side Object Model, it just takes a little more code.   If you don’t have access to the SharePoint server this is a great option with flexibility to host a PowerShell script anywhere (desktop, job server, etc.)


2-24-2012 3-32-35 PM
2-24-2012 3-31-46 PM


Server Side Object Model

Client Side Object Model

  • Pingback: CLOM : Client Object Model ou comment travailler en distant sur votre ferme (même en ADFS) , The Mit's Blog()

  • regarding line: $context = New-Object Microsoft.SharePoint.Client.ClientContext($siteUrl) I am getting an invalid type message. I am running Windows 7 x64. Do I need to do anything special? (*using the client side object model)

    • Probably need to download “SharePoint Foundation 2010 Client Object Model Redistributable” I run most of my code directly on a SP2010 server so all of those DLLs are installed. On a workstation (Client Side Object Model) you need to run the MSI to install the DLLs locally.

      • Thanks! Sorry I did not see your reply earlier!

  • tburgess

    this is exactly what I was looking for, but I am getting a (401) Unauthorized on $context.ExecuteQuery(). MY account is a farm admin as well on the site and list.

    Exception calling “ExecuteQuery” with “0” argument(s): “The remote server returned an error: (401) Unauthorized.”
    At line:12 char:26
    + $context.ExecuteQuery <<<< ();
    + CategoryInfo : NotSpecified: (:) [], MethodInvocationException
    + FullyQualifiedErrorId : DotNetMethodException

© Copyright 2016
@ SPJeff

Return to Top ▲Return to Top ▲