Date post: | 09-May-2015 |
Category: |
Technology |
Upload: | nccomms |
View: | 867 times |
Download: | 2 times |
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
Antipattern: Mechanical Turk
Fail Often, Fail FastTo err is human
What about SharePoint Onpremise?
Cloud ReadyStuff that deploys on SharePoint Online should also deploy On Premises
Cloud ReadyDev on premise, deploy to the cloud
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
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
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
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/)
Final thoughts
sponlinecmdlets.codeplex.com
spcb.codeplex.com
Links
Cmdlets:
http://msdn.microsoft.com/en-us/library/system.management.automation.cmdlet%28v=vs.85%29.aspx
SharePoint Online and Onpremise cmdlets:
http://blog.blksthl.com/2013/01/15/sharepoint-2013-powershell-cmdlets-listed-onprem-vs-online/
Service locator pattern in C#:
http://stefanoricciardi.com/2009/09/25/service-locator-pattern-in-csharpa-simple-example/
Office 365 / SharePoint Online demos:
https://www.microsoftofficedemos.com/