Getting Started with Office 365 and the Client Side Object Model – CSOM

SharePoint 2013 included some huge improvements to the Client Side Object Model, as more and more of the customers that I work with are moving to Office 365 I need to start thinking about updating the various scripts that I have to use CSOM. This is critical as my collection of scripts have been exclusively been written to make use of the Server Object Model - which I'm never, ever going to be able to access in Office 365 🙂

The beauty of CSOM is that the scripts can be run remotely, as long as you have sufficient permissions to the SharePoint site these can be run from your local machine!

One of the pre-requisites of using the CSOM is the SharePoint 2013 client side assemblies which need to be installed on the machine that is running the script, these are included in the SharePoint Server 2013 Client Components SDK which can be downloaded from here - http://www.microsoft.com/en-us/download/details.aspx?id=35585.

To get me started, I've written a super-basic script that connects to a Site within an Office 365 tenant and updates the Title and Description - that is all! As I become more proficient with CSOM, I will share my learning with the Blog. The script will prompt for the username and password, all you need to do is update the URL and the Title and Description (highlighted) to get this to work!

#Connect to site within the tenant and update the title and description$Web = $Context.Web$Context.Load($Web)$Web.Title = "New Title"$Web.Description = "New Description"$Web.Update()$Context.ExecuteQuery()