SlideShare une entreprise Scribd logo
1  sur  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

Contenu connexe

Plus de NCCOMMS

Plus 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
 

Dernier

Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
Joaquim Jorge
 

Dernier (20)

Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CV
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
Top 10 Most Downloaded Games on Play Store in 2024
Top 10 Most Downloaded Games on Play Store in 2024Top 10 Most Downloaded Games on Play Store in 2024
Top 10 Most Downloaded Games on Play Store in 2024
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 

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/

Notes de l'éditeur

  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