Extending Powershell with the Client Side Object Model About me #SPRUNNERS @rbethleh [email protected] Developing for SharePoint Online How can we make development repeatable How to get to Continuous Integration across Development, Test, Acceptance and Production Microsoft only gave us SharePoint Online Admin Tenant CmdLets SharePoint Online has 27 cmdlets SharePoint Onpremise has 730 cmdlets Antipattern: Mechanical Turk To err is human Fail Often, Fail Fast, Fail Cheap What about SharePoint Onpremise? Stuff that deploys on SharePoint Online should also deploy OnPremise Dev on premise, deploy to the cloud So what can you do? (Sandboxed) Event Receivers rative: Onet.xml, webtemplates, les wrapped in WSP rePoint Online Powershell CmdLets Client Side Object Model (CSOM) Script Object Model 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 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 Userprofile properties Audiences Activate a sandbox solution Use DesignPackageInfo Trust apps Search Schema such as Managed properties (although you can export config) Final thoughts sponlinecmdlets.codeplex.com spcb.codeplex.com Links Cmdlets: http://msdn.microsoft.com/enus/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-vsonline/ Service locator pattern in C#: http://stefanoricciardi.com/2009/09/25/service-locator-pattern-in-csharpa-simple-example/
© Copyright 2026 Paperzz