SlideShare una empresa de Scribd logo
1 de 13
Extending Powershell with the
Client Side Object Model
About me

#SPRUNNERS

@rbethleh
roelhans.bethlehem@rapidcircle.com
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
What about SharePoint
Onpremise?
Cloud Ready
Stuff that deploys on SharePoint Online
should also deploy On Premises

Cloud Ready
Dev on premise, deploy to the cloud
So what can you do?

(Sandboxed) Event Receivers

rative:
xml, webtemplates, modules
ped 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
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
Userprofile properties
Audiences
Deploy/Trust apps: Check out app
stapling -

Activate a sandbox solut
Use DesignPackageInfo –
codeplex (idea from

http://blog.symprogress.com/201
pply-designpackage-using-client-o
model/)

http://blogs.msdn.com/b/richard_dizeregas_blog/arch
ive/2013/03/04/sharepoint-2013-app-deploymentthrough-quot-app-stapling-quot.aspx

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/

Office 365 / SharePoint Online demos:
https://www.microsoftofficedemos.com/
SPCA2013 - Extending Powershell with the Client Side Object Model

Más contenido relacionado

Más de NCCOMMS

Más de NCCOMMS (20)

O365Con19 - Model-driven Apps or Canvas Apps? - Rick Bakker
O365Con19 - Model-driven Apps or Canvas Apps? - Rick BakkerO365Con19 - Model-driven Apps or Canvas Apps? - Rick Bakker
O365Con19 - Model-driven Apps or Canvas Apps? - Rick Bakker
 
O365Con19 - Office 365 Groups Surviving the Real World - Jasper Oosterveld
O365Con19 - Office 365 Groups Surviving the Real World - Jasper OosterveldO365Con19 - Office 365 Groups Surviving the Real World - Jasper Oosterveld
O365Con19 - Office 365 Groups Surviving the Real World - Jasper Oosterveld
 
O365Con19 - Developing Timerjob and Eventhandler Equivalents - Adis Jugo
O365Con19 - Developing Timerjob and Eventhandler Equivalents - Adis JugoO365Con19 - Developing Timerjob and Eventhandler Equivalents - Adis Jugo
O365Con19 - Developing Timerjob and Eventhandler Equivalents - Adis Jugo
 
O365Con19 - Sharepoint with (Artificial) Intelligence - Adis Jugo
O365Con19 - Sharepoint with (Artificial) Intelligence - Adis JugoO365Con19 - Sharepoint with (Artificial) Intelligence - Adis Jugo
O365Con19 - Sharepoint with (Artificial) Intelligence - Adis Jugo
 
O365Con19 - What Do You Mean 90 days Isn't Enough - Paul Hunt
O365Con19 - What Do You Mean 90 days Isn't Enough - Paul HuntO365Con19 - What Do You Mean 90 days Isn't Enough - Paul Hunt
O365Con19 - What Do You Mean 90 days Isn't Enough - Paul Hunt
 
O365Con19 - Tips and Tricks for Complex Migrations to SharePoint Online - And...
O365Con19 - Tips and Tricks for Complex Migrations to SharePoint Online - And...O365Con19 - Tips and Tricks for Complex Migrations to SharePoint Online - And...
O365Con19 - Tips and Tricks for Complex Migrations to SharePoint Online - And...
 
O365Con19 - Start Developing Teams Tabs and SharePoint Webparts with SPFX - O...
O365Con19 - Start Developing Teams Tabs and SharePoint Webparts with SPFX - O...O365Con19 - Start Developing Teams Tabs and SharePoint Webparts with SPFX - O...
O365Con19 - Start Developing Teams Tabs and SharePoint Webparts with SPFX - O...
 
O365Con19 - Start Your Journey from Skype for Business to Teams - Sasja Beere...
O365Con19 - Start Your Journey from Skype for Business to Teams - Sasja Beere...O365Con19 - Start Your Journey from Skype for Business to Teams - Sasja Beere...
O365Con19 - Start Your Journey from Skype for Business to Teams - Sasja Beere...
 
O365Con19 - Lets Get Started with Azure Container Instances - Jussi Roine
O365Con19 - Lets Get Started with Azure Container Instances - Jussi RoineO365Con19 - Lets Get Started with Azure Container Instances - Jussi Roine
O365Con19 - Lets Get Started with Azure Container Instances - Jussi Roine
 
O365Con19 - Azure Blackbelt - Jussi Roine
O365Con19 - Azure Blackbelt - Jussi RoineO365Con19 - Azure Blackbelt - Jussi Roine
O365Con19 - Azure Blackbelt - Jussi Roine
 
O365Con19 - Customise the UI in Modern SharePoint Workspaces - Corinna Lins
O365Con19 - Customise the UI in Modern SharePoint Workspaces - Corinna LinsO365Con19 - Customise the UI in Modern SharePoint Workspaces - Corinna Lins
O365Con19 - Customise the UI in Modern SharePoint Workspaces - Corinna Lins
 
O365Con19 - Be The Protagonist of Your Modern Workplace - Corinna Lins
O365Con19 - Be The Protagonist of Your Modern Workplace - Corinna LinsO365Con19 - Be The Protagonist of Your Modern Workplace - Corinna Lins
O365Con19 - Be The Protagonist of Your Modern Workplace - Corinna Lins
 
O365Con19 - How to Really Manage all your Tasks Across Microsoft 365 - Luise ...
O365Con19 - How to Really Manage all your Tasks Across Microsoft 365 - Luise ...O365Con19 - How to Really Manage all your Tasks Across Microsoft 365 - Luise ...
O365Con19 - How to Really Manage all your Tasks Across Microsoft 365 - Luise ...
 
O365Con19 - Sharing Code Efficiently in your Organisation - Elio Struyf
O365Con19 - Sharing Code Efficiently in your Organisation - Elio StruyfO365Con19 - Sharing Code Efficiently in your Organisation - Elio Struyf
O365Con19 - Sharing Code Efficiently in your Organisation - Elio Struyf
 
O365Con19 - Things I've Learned While Building a Product on SharePoint Modern...
O365Con19 - Things I've Learned While Building a Product on SharePoint Modern...O365Con19 - Things I've Learned While Building a Product on SharePoint Modern...
O365Con19 - Things I've Learned While Building a Product on SharePoint Modern...
 
O365Con19 - Keep Control of Your Data with AIP and CA - Bram de Jager
O365Con19 - Keep Control of Your Data with AIP and CA - Bram de JagerO365Con19 - Keep Control of Your Data with AIP and CA - Bram de Jager
O365Con19 - Keep Control of Your Data with AIP and CA - Bram de Jager
 
O365Con19 - Kaizala a Dive Into the Unknown - Rick van Rousselt
O365Con19 - Kaizala a Dive Into the Unknown - Rick van RousseltO365Con19 - Kaizala a Dive Into the Unknown - Rick van Rousselt
O365Con19 - Kaizala a Dive Into the Unknown - Rick van Rousselt
 
O365Con19 - How to Inspire Users to Unstick from Email - Luise Freese
O365Con19 - How to Inspire Users to Unstick from Email - Luise FreeseO365Con19 - How to Inspire Users to Unstick from Email - Luise Freese
O365Con19 - How to Inspire Users to Unstick from Email - Luise Freese
 
O365Con19 - O365 Identity Management and The Golden Config - Chris Goosen
O365Con19 - O365 Identity Management and The Golden Config - Chris GoosenO365Con19 - O365 Identity Management and The Golden Config - Chris Goosen
O365Con19 - O365 Identity Management and The Golden Config - Chris Goosen
 
O365Con19 - Exposing Multi-Geo Capabilities in Office 365 - Paul Hunt
O365Con19 - Exposing Multi-Geo Capabilities in Office 365 - Paul HuntO365Con19 - Exposing Multi-Geo Capabilities in Office 365 - Paul Hunt
O365Con19 - Exposing Multi-Geo Capabilities in Office 365 - Paul Hunt
 

Último

Breaking Down the Flutterwave Scandal What You Need to Know.pdf
Breaking Down the Flutterwave Scandal What You Need to Know.pdfBreaking Down the Flutterwave Scandal What You Need to Know.pdf
Breaking Down the Flutterwave Scandal What You Need to Know.pdf
UK Journal
 

Último (20)

Powerful Start- the Key to Project Success, Barbara Laskowska
Powerful Start- the Key to Project Success, Barbara LaskowskaPowerful Start- the Key to Project Success, Barbara Laskowska
Powerful Start- the Key to Project Success, Barbara Laskowska
 
WebAssembly is Key to Better LLM Performance
WebAssembly is Key to Better LLM PerformanceWebAssembly is Key to Better LLM Performance
WebAssembly is Key to Better LLM Performance
 
Choosing the Right FDO Deployment Model for Your Application _ Geoffrey at In...
Choosing the Right FDO Deployment Model for Your Application _ Geoffrey at In...Choosing the Right FDO Deployment Model for Your Application _ Geoffrey at In...
Choosing the Right FDO Deployment Model for Your Application _ Geoffrey at In...
 
Linux Foundation Edge _ Overview of FDO Software Components _ Randy at Intel.pdf
Linux Foundation Edge _ Overview of FDO Software Components _ Randy at Intel.pdfLinux Foundation Edge _ Overview of FDO Software Components _ Randy at Intel.pdf
Linux Foundation Edge _ Overview of FDO Software Components _ Randy at Intel.pdf
 
Using IESVE for Room Loads Analysis - UK & Ireland
Using IESVE for Room Loads Analysis - UK & IrelandUsing IESVE for Room Loads Analysis - UK & Ireland
Using IESVE for Room Loads Analysis - UK & Ireland
 
Your enemies use GenAI too - staying ahead of fraud with Neo4j
Your enemies use GenAI too - staying ahead of fraud with Neo4jYour enemies use GenAI too - staying ahead of fraud with Neo4j
Your enemies use GenAI too - staying ahead of fraud with Neo4j
 
A Business-Centric Approach to Design System Strategy
A Business-Centric Approach to Design System StrategyA Business-Centric Approach to Design System Strategy
A Business-Centric Approach to Design System Strategy
 
Breaking Down the Flutterwave Scandal What You Need to Know.pdf
Breaking Down the Flutterwave Scandal What You Need to Know.pdfBreaking Down the Flutterwave Scandal What You Need to Know.pdf
Breaking Down the Flutterwave Scandal What You Need to Know.pdf
 
Microsoft CSP Briefing Pre-Engagement - Questionnaire
Microsoft CSP Briefing Pre-Engagement - QuestionnaireMicrosoft CSP Briefing Pre-Engagement - Questionnaire
Microsoft CSP Briefing Pre-Engagement - Questionnaire
 
ECS 2024 Teams Premium - Pretty Secure
ECS 2024   Teams Premium - Pretty SecureECS 2024   Teams Premium - Pretty Secure
ECS 2024 Teams Premium - Pretty Secure
 
Portal Kombat : extension du réseau de propagande russe
Portal Kombat : extension du réseau de propagande russePortal Kombat : extension du réseau de propagande russe
Portal Kombat : extension du réseau de propagande russe
 
How we scaled to 80K users by doing nothing!.pdf
How we scaled to 80K users by doing nothing!.pdfHow we scaled to 80K users by doing nothing!.pdf
How we scaled to 80K users by doing nothing!.pdf
 
Long journey of Ruby Standard library at RubyKaigi 2024
Long journey of Ruby Standard library at RubyKaigi 2024Long journey of Ruby Standard library at RubyKaigi 2024
Long journey of Ruby Standard library at RubyKaigi 2024
 
Google I/O Extended 2024 Warsaw
Google I/O Extended 2024 WarsawGoogle I/O Extended 2024 Warsaw
Google I/O Extended 2024 Warsaw
 
Overview of Hyperledger Foundation
Overview of Hyperledger FoundationOverview of Hyperledger Foundation
Overview of Hyperledger Foundation
 
PLAI - Acceleration Program for Generative A.I. Startups
PLAI - Acceleration Program for Generative A.I. StartupsPLAI - Acceleration Program for Generative A.I. Startups
PLAI - Acceleration Program for Generative A.I. Startups
 
Simplified FDO Manufacturing Flow with TPMs _ Liam at Infineon.pdf
Simplified FDO Manufacturing Flow with TPMs _ Liam at Infineon.pdfSimplified FDO Manufacturing Flow with TPMs _ Liam at Infineon.pdf
Simplified FDO Manufacturing Flow with TPMs _ Liam at Infineon.pdf
 
BT & Neo4j _ How Knowledge Graphs help BT deliver Digital Transformation.pptx
BT & Neo4j _ How Knowledge Graphs help BT deliver Digital Transformation.pptxBT & Neo4j _ How Knowledge Graphs help BT deliver Digital Transformation.pptx
BT & Neo4j _ How Knowledge Graphs help BT deliver Digital Transformation.pptx
 
FDO for Camera, Sensor and Networking Device – Commercial Solutions from VinC...
FDO for Camera, Sensor and Networking Device – Commercial Solutions from VinC...FDO for Camera, Sensor and Networking Device – Commercial Solutions from VinC...
FDO for Camera, Sensor and Networking Device – Commercial Solutions from VinC...
 
Behind the Scenes From the Manager's Chair: Decoding the Secrets of Successfu...
Behind the Scenes From the Manager's Chair: Decoding the Secrets of Successfu...Behind the Scenes From the Manager's Chair: Decoding the Secrets of Successfu...
Behind the Scenes From the Manager's Chair: Decoding the Secrets of Successfu...
 

SPCA2013 - Extending Powershell with the Client Side Object Model

  • 1.
  • 2. Extending Powershell with the Client Side Object Model
  • 4. 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
  • 5. Antipattern: Mechanical Turk To err is human Fail Often, Fail Fast
  • 6. What about SharePoint Onpremise? Cloud Ready Stuff that deploys on SharePoint Online should also deploy On Premises Cloud Ready Dev on premise, deploy to the cloud
  • 7. So what can you do? (Sandboxed) Event Receivers rative: xml, webtemplates, modules ped in WSP rePoint Online Powershell CmdLets Client Side Object Model (CSOM) Script Object Model Powershell + Client Side Object Model
  • 8. 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
  • 9. 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
  • 10. Restrictions Userprofile properties Audiences Deploy/Trust apps: Check out app stapling - Activate a sandbox solut Use DesignPackageInfo – codeplex (idea from http://blog.symprogress.com/201 pply-designpackage-using-client-o model/) http://blogs.msdn.com/b/richard_dizeregas_blog/arch ive/2013/03/04/sharepoint-2013-app-deploymentthrough-quot-app-stapling-quot.aspx Search Schema such as Managed properties (although you can export config)
  • 12. 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/ Office 365 / SharePoint Online demos: https://www.microsoftofficedemos.com/

Notas del editor

  1. Stress the importance of SharePoint OnlineStress the need for repeatable qualitative developmentExample: client had a checked in JS file 1.000 times in 2 years
  2. Example: clickingeverythingtogether in AcceptanceandProductionFor mechanical turk tobeeffectiveyouneeded a goodchessplayer in the machineToerr is human andthatbrings me toanother point in developmentwhichseemstocontradicteverything:Failoften, failfast; learnoften, learnfastThe point being is thatwhat we finallydeliver is somethinggood, somethingthatsucceedsSchool teaches you to think stuff through and not fail; I had to unlearn that, its ok to fail, just make sure it does not cost much
  3. Onpremise we can test but we can also expect to see the same problem onpremise as we see online.Online might take a few hours before the log entry becomes available.Dev – On Premise, Test + Accept + Production - Online
  4. Sandboxed event receivers was my weapon of choice in the past. No longer since partial trusted code is deprecated.Still using sandbox to deploy stuff declaratively – MS is using this in its own Design Manager in 15
  5. Demo 1: Creating the cmdlet that works for both SharePoint Online and SharePoint Onpremise1. Show the template in the template directory2. Inherit from System.Management.Automation.PSCmdlet3. Decorate the class with System.Management.Automation.Cmdlet so you can set the name of the cmdlet4. Context is built up, need to authenticate, just a type of ICredentials for both SharePoint Online and SharePoint Onpremise5. So I used a simple servicelocator to load the correct authentication6. Rename the method where you do the actual work, add the line: this.WriteObject(string.Format(&quot;Web name: {0}&quot;, web.Title));7. Build it8. Onpremise: Get-Webname -Url http://suguk.rapidcircle-dev.com -User rbethleh -Password Oostakker39 -AuthenticationMethodOnPremise -Domain rapidcircle-dev -Verbose9. Online: Get-Webname -Url https://afghanwhigs.sharepoint.com -User admin@afghanwhigs.onmicrosoft.com -Password pass@word1 -AuthenticationMethodSharePointOnline -Verbose10. So in effect I can use the same cmdlet both in Online and OnPremiseDemo 2: Doing something more complicated, provisioning a sitecolumn and contenttype where the sitecolumn contains a taxonomy field.1. Open the project suguk which is a standard sandbox project defining a sitecolumn of type taxonomy field and point out that you cannot associate the taxonomy2. Open up the taxonomy and show the country3. Show the contenttype Member, we just want to be able to select the country the member is from.4. Show the feature that is to be deployed5. Show the package. Build the package to the build directory6. Now in order to provision this we will need a cmdlet to associate the thetaxonomyfield with the taxonomy itself (as we probably do not know the guids at design time)7. Enter the cmdlet8. Show the implementation of the method9. Open the Powershell ISE, first the dev script (watch that the site does not exist). Point out that we create a sitecollection, upload the package activate it and deploy sandbox solution then run the cmdlet to associate taxonomy10. Open the test script, do the same, activate sandbox solution manually, rest is the same11. Create lists of members