13

Extending SharePoint Online Powershell using CSOM

Embed Size (px)

DESCRIPTION

How to write your own cmdlets for SharePoint Online and SharePoint On-Premises. For the source code see: sponlinecmdlets.codeplex.com.

Citation preview

Page 1: Extending SharePoint Online Powershell using CSOM
Page 2: Extending SharePoint Online Powershell using CSOM

Extending Powershell with the Client Side Object Model

Page 3: Extending SharePoint Online Powershell using CSOM

#SPRUNNERS

@rbethleh

About me

[email protected]

Page 4: Extending SharePoint Online Powershell using CSOM

Developing for SharePoint Online

Microsoft only gave us SharePoint Online Admin Tenant CmdLets

How can we make development repeatable

How to get to Continuous Integration across Development, Test, Acceptance and Production

SharePoint Online has 27 cmdletsSharePoint Onpremise has 730 cmdlets

Roel Hans Bethlehem
What is a cmdlet
Page 5: Extending SharePoint Online Powershell using CSOM

Antipattern: Mechanical Turk

Fail Often, Fail FastTo err is human

Page 6: Extending SharePoint Online Powershell using CSOM

What about SharePoint Onpremise?

Cloud ReadyStuff that deploys on SharePoint Online should also deploy On Premises

Cloud ReadyDev on premise, deploy to the cloud

Page 7: Extending SharePoint Online Powershell using CSOM

So what can you do?

Declarative: Onet.xml, webtemplates, modules wrapped in WSP

(Sandboxed) Event Receivers

Client Side Object Model (CSOM)

JavaScript Object Model

SharePoint Online Powershell CmdLets

Powershell + Client Side Object Model

Page 8: Extending SharePoint Online Powershell using CSOM

So what did I do?

Started out with Powershell

Powershell does not know about Generics

ClientContext.Load(<type>);

So: Roll your own cmdlet since .NET does not have this restriction

Page 9: Extending SharePoint Online Powershell using CSOM

Demo

Create taxonomy field in both Sharepoint Online and SharePoint onpremise

Extending with Powershell

● System.Management.Automation.PSCmdLet ● Decorate the class with attributes● Override ProcessRecord method● Use a Service Locator Pattern to dynamically load credential class● Upload and deploy Sandbox Solution automagically● Do some stuff to SharePoint Online / SharePoint OnPremise to finish taxonomy

field

Ingredients

● Sandbox solution defining contenttype● Loaded termset● Both a SharePoint OnPremise server and SharePoint Online tenant● Powershell cmdlet Set-TaxonomyFieldAssociation● SharePoint Client Browser

Page 10: Extending SharePoint Online Powershell using CSOM

Restrictions

Search Schema such as Managed properties (although you can export config)

Userprofile properties

Audiences

Deploy/Trust apps: Check out app stapling - http://blogs.msdn.com/b/richard_dizeregas_blog/archive/2013/03/04/sharepoint-2013-app-deployment-through-quot-app-stapling-quot.aspx

Activate a sandbox solutionUse DesignPackageInfo – see codeplex (idea from http://blog.symprogress.com/2013/07/apply-designpackage-using-client-object-model/)

Page 11: Extending SharePoint Online Powershell using CSOM

Final thoughts

sponlinecmdlets.codeplex.com

spcb.codeplex.com

Page 13: Extending SharePoint Online Powershell using CSOM