Managing (O365) with PowerShell + CSOM

31
Managing (O365) with PowerShell + CSOM

Transcript of Managing (O365) with PowerShell + CSOM

Page 1: Managing (O365) with PowerShell + CSOM

Managing (O365) with PowerShell + CSOM

Page 2: Managing (O365) with PowerShell + CSOM

GO

LD

RA

FF

LE

SIL

VE

RPLATINUM

Page 3: Managing (O365) with PowerShell + CSOM

HELLO!My name is

Amit VasuSr. SharePoint Consultant, MVPwww.amitvasu.com

Twitter: @amitvasu

Page 4: Managing (O365) with PowerShell + CSOM

Session Objective

Understand how to automate different SharePoint Online (Office 365) tasks using PowerShell and CSOM

This session is for Developers

And IT Pro as well

……May be NOT

Page 5: Managing (O365) with PowerShell + CSOM

History LessonAmit’s PowerShell + CSOM Journey

Page 6: Managing (O365) with PowerShell + CSOM

“FTC to CAM – Stop creating content types and site columns declaratively”

http://blogs.msdn.com/b/vesku/archive/2013/11/06/ftc-to-cam-stop-creating-content-types-and-site-columns-declaratively.aspx

Page 7: Managing (O365) with PowerShell + CSOM

Typical CT deployment process

Page 8: Managing (O365) with PowerShell + CSOM

How do we overcome - On Premises

Page 9: Managing (O365) with PowerShell + CSOM

What are the challenges with O365

Guidance to not use declarative code for CT

You cannot use custom code in Sandbox solution.

Farm solutions are out of question.

Page 10: Managing (O365) with PowerShell + CSOM

Remote Provisioning to Rescue

Page 11: Managing (O365) with PowerShell + CSOM

Remote Provisioning

Write C# CSOM/REST Provider hosted App

JSOM

PowerShell + CSOM

Page 12: Managing (O365) with PowerShell + CSOM

SharePoint Farm1

Provider Hosted

Apps

Own app specific

configuration

Artefacts

24

CSOM / REST

3

Remote Provisioning Process – CSOM/REST

Page 13: Managing (O365) with PowerShell + CSOM

CSOM – Power Talk

Page 14: Managing (O365) with PowerShell + CSOM

Remote Provisioning

Client side library for remotely communicating with SharePoint

Introduced in SharePoint 2010

Expanded upon in SharePoint 2013

Page 15: Managing (O365) with PowerShell + CSOM

CSOM in SharePoint 2010

Page 16: Managing (O365) with PowerShell + CSOM

CSOM in SharePoint 2013

Page 17: Managing (O365) with PowerShell + CSOM

How CSOM Works

Page 18: Managing (O365) with PowerShell + CSOM

CSOM – Code Example

Create Context

ClientContext ctx = new ClientContext("http://intranet.contoso.com");

Call Load and ExecuteQuery Before Accessing Value Properties

Web web = ctx.Web;

ctx.Load(web);

ctx.ExecuteQuery();

Console.WriteLine(web.Title);

Page 19: Managing (O365) with PowerShell + CSOM

How do I start

Page 20: Managing (O365) with PowerShell + CSOM

Steps to start developing

Pick your Development environment

Local Machine

SharePoint 2013 Environment

Page 21: Managing (O365) with PowerShell + CSOM

Local Machine

Required copy of all SharePoint Client DLL

Located at C:\Program Files\Common Files\microsoft shared\Web Server Extensions\15\ISAPI

All DLLs that starts with Microsoft.SharePoint.Client

Reference them in your code from the location you copied them

Page 22: Managing (O365) with PowerShell + CSOM

SharePoint Environment

No need to do anything other than referencing DLLs from ISAPI folder.

Page 23: Managing (O365) with PowerShell + CSOM

Optional – Download CSOM Assemblies

Page 24: Managing (O365) with PowerShell + CSOM

DEMOPowerShell + CSOM

Page 25: Managing (O365) with PowerShell + CSOM

Summary

Page 26: Managing (O365) with PowerShell + CSOM

Why PowerShell + CSOM

Anything you can do with CSOM can be achieved using PowerShell + CSOM

Great way to extend PowerShell capabilities

Can be used with SharePoint Online and On-premises

Spend time understanding CSOM

Microsoft.SharePoint.Client namespace

Page 27: Managing (O365) with PowerShell + CSOM

Resources

https://sharepointpowershell.codeplex.com/

https://sharepointonlineautomationcmdlets.codeplex.com/

http://social.technet.microsoft.com/wiki/contents/articles/29518.csom-sharepoint-powershell-reference-and-example-codes.aspx

Page 28: Managing (O365) with PowerShell + CSOM

GO

LD

RA

FF

LE

SIL

VE

RPLATINUM

Page 29: Managing (O365) with PowerShell + CSOM

Thank you!Toronto Enterprise Collaboration User GroupChange Management, Governance, SharePoint, Office 365, Yammer, PowerBI, etc

http://www.meetup.com/TSPBUG/Toronto SharePoint Business Users Grouphttp://www.meetup.com/TorontoSPUG/

Saturday July 9, 2016

See you next year!

Page 30: Managing (O365) with PowerShell + CSOM

EVALS

http://spbuzz.it/spsto2015-evals

Page 31: Managing (O365) with PowerShell + CSOM

THANK YOU