spca2013 - extending powershell with the client side object model

13

Upload: nccomms

Post on 09-May-2015

868 views

Category:

Technology


2 download

DESCRIPTION

Extending Powershell with the Client Side Object Model

TRANSCRIPT

Page 1: SPCA2013 - Extending Powershell with the Client Side Object Model
Page 2: SPCA2013 - Extending Powershell with the Client Side Object Model

Extending Powershell with the Client Side Object Model

Page 3: SPCA2013 - Extending Powershell with the Client Side Object Model

#SPRUNNERS

@rbethleh

About me

[email protected]

Page 4: SPCA2013 - Extending Powershell with the Client Side Object Model

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: SPCA2013 - Extending Powershell with the Client Side Object Model

Antipattern: Mechanical Turk

Fail Often, Fail FastTo err is human

Page 6: SPCA2013 - Extending Powershell with the Client Side Object Model

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: SPCA2013 - Extending Powershell with the Client Side Object Model

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: SPCA2013 - Extending Powershell with the Client Side Object Model

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: SPCA2013 - Extending Powershell with the Client Side Object Model

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: SPCA2013 - Extending Powershell with the Client Side Object Model

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: SPCA2013 - Extending Powershell with the Client Side Object Model

Final thoughts

sponlinecmdlets.codeplex.com

spcb.codeplex.com

Page 13: SPCA2013 - Extending Powershell with the Client Side Object Model