+ All Categories
Home > Technology > SharePoint Saturday Cincinnati 2014 - CSOM

SharePoint Saturday Cincinnati 2014 - CSOM

Date post: 12-Jun-2015
Category:
Upload: ryan-dennis
View: 243 times
Download: 1 times
Share this document with a friend
Description:
With the growing adoption of Office 365 and SharePoint Online and the continued prevalence of SharePoint on-premises, it’s becoming more difficult to manage both environments in an automated fashion. While SharePoint Online does have native support for Windows PowerShell, there are very few cmdlets to manage the sites and site contents. SharePoint on-premises gives us well over 700 cmdlets, but it still doesn’t answer every situational scenario – leaving gaps in functionality which can be filled by scripters. In this demo-heavy session, focused on both the developer AND the administrator – you’ll see how you can use one shell to manage both scenarios (on-premises and Office 365). Demonstrations will focus on building PowerShell Scripts and Advanced Functions for both target environments, and by the end of the session you’ll be ready to start Managing SharePoint Anywhere with PowerShell.
Popular Tags:
26
Managing SharePoint Anywhere with Windows PowerHell Ryan Dennis
Transcript
Page 1: SharePoint Saturday Cincinnati 2014 - CSOM

Managing SharePoint Anywhere with Windows

PowerHellRyan Dennis

Page 2: SharePoint Saturday Cincinnati 2014 - CSOM
Page 3: SharePoint Saturday Cincinnati 2014 - CSOM

Join us for SharePint

Location: Sharonville Convention Center

Follow the SIGNS if you dare

Sponsored by Accusoft & Focal Point Solutions

Page 4: SharePoint Saturday Cincinnati 2014 - CSOM

Sponsors

Platinum:

Gold:

Bronze:

Page 5: SharePoint Saturday Cincinnati 2014 - CSOM

Let’s Get Social !

Twitter: @spscincinnati #spspookinnati

Mobile: www.spsmobile.com

Check us out on Facebook: https://www.facebook.com/sp

scincy

Page 6: SharePoint Saturday Cincinnati 2014 - CSOM

Submit your feedback! Go to http://SPSMobile.com

He was awesome!

[email protected]

Page 7: SharePoint Saturday Cincinnati 2014 - CSOM

Ryan DennisSenior SharePoint Consultant at Blue Chip Consulting Group

Recently published first book as a co-author

www.bluechip-llc.com

[email protected]

@SharePointRyan

/in/SharePointRyan

/SharePointRyanDotCom

www.sharepointryan.com

SP Geek Father

Drummer

Scripter Author

Husband

http://bit.ly/MMS13book

Page 8: SharePoint Saturday Cincinnati 2014 - CSOM

Get-Agenda

• Housekeeping• Intro to Advanced Functions• SharePoint PowerShell On-Premise• SharePoint PowerShell in Office 365• Using Client Side Object Model

(CSOM) code in PowerShell• Q&A

Page 9: SharePoint Saturday Cincinnati 2014 - CSOM

Get-Help –Topic “PowerShell”

…is a task-based command-line shell and scripting language designed especially for Windows system administration

…has a task-based scripting language

…includes powerful object manipulation capabilities

…is built on the .NET Framework

Page 10: SharePoint Saturday Cincinnati 2014 - CSOM

Verb-Noun

PowerShell uses a Verb-Noun syntax for its Cmdlets• Get-Something• Set-Something• New-Something• Remove-Something

Quick Tip!Use Get-Verb to find approved verbs! Use

Verb-Noun in your code!

Page 11: SharePoint Saturday Cincinnati 2014 - CSOM

• Use Get-Command to see available commandsGet-Command –Module Microsoft.SharePoint.PowerShellGet-Command –Module Microsoft.Online.SharePoint.PowerShell

• Use Get-Help <CmdletName> to get help information for a cmdlet

Get-Command & Get-Help

Quick Tip!Add Help to your

scripts and functions!

Page 12: SharePoint Saturday Cincinnati 2014 - CSOM

• SharePoint 2010– 500+ Cmdlets…– MUCH better than STSADM.exe in prior versions…– Can automate complete installations and

configurations…

• SharePoint 2013– 700+ Cmdlets!

• Still doesn’t answer every scenario, leaving gaps in functionality…– Example: Get, New and Remove SharePoint Groups – no cmdlet, easy to write a

custom function though…

Get-Command –Type “SharePoint”

Opportunity!Write our own

scripts and functions!

Page 13: SharePoint Saturday Cincinnati 2014 - CSOM

Get-Help About_Functions_Advanced

…allow you to perform operations that are similar to the operations you can perform with cmdlets…quickly write a function without having to write a compiled cmdlet using a Microsoft .NET Framework language (C#)…use the CmdletBinding() attribute to identify them as functions that act similar to cmdlets

Quick Tip!Use Get-Help

About_Functions_Advanced for more info!

Page 14: SharePoint Saturday Cincinnati 2014 - CSOM

New-Function –Name “Our First Function”• Leverages all of the Write-* cmdlets

in the Microsoft.PowerShell.Utility module

• Includes Switch statement, ValidateSet, Try/Catch/Finally, etc.

• Includes comment-based-help with examples

• Can be run just like a cmdletDisclaimer!

This is NOT a SharePoint demo, just a general PowerShell

demo!

Page 15: SharePoint Saturday Cincinnati 2014 - CSOM

D E M OWrite-Message

Page 16: SharePoint Saturday Cincinnati 2014 - CSOM

Get-Recap

• Reviewed Write-Message function…• Created output using all Write* types• Saw the behavior of –Verbose and –

Debug switches• Had some fun…

Page 17: SharePoint Saturday Cincinnati 2014 - CSOM
Page 18: SharePoint Saturday Cincinnati 2014 - CSOM

Get-Info “SP PowerShell On-Premises”

• Uses the Microsoft.SharePoint.PowerShell snap-in

• Access to hundreds* of native cmdlets

• Script using Server Side Object Model Code

• Run as default (administrative) user• Must have server access

*782 cmdlets on my SP 2013 April 2014 CU

farm.

Page 19: SharePoint Saturday Cincinnati 2014 - CSOM

Get-Info “SP PowerShell O365”• Uses the

Microsoft.Online.SharePoint.PowerShell module

• Access to thirty* (30) native cmdlets• Script using Client Side Object Model

Code• Provide user credentials for

ClientContext• No need for server access*30 cmdlets as

of 9/19/2014.

Page 20: SharePoint Saturday Cincinnati 2014 - CSOM

Get-Started -with “SP Online Scripting”

• Download the SharePoint Online Management Shell

• Use Connect-SPOService to connect to your Tenant SharePoint Administration Site

• Use Get-Command –Module Microsoft.Online.SharePoint.PowerShell to see the available cmdlets

Page 21: SharePoint Saturday Cincinnati 2014 - CSOM

Get-Intro –Topic “SharePoint CSOM”

• Add the following Assemblies–Microsoft.SharePoint.Client.dll–Microsoft.SharePoint.Client.Runtime.dll

• Create a Client.Context variable• Call the Load() and ExecuteQuery()

methods• Once context is created, get and set

properties…For help on writing

CSOM, see http://bit.ly/Msdn

Csom

Page 22: SharePoint Saturday Cincinnati 2014 - CSOM

D E M OSharePoint Online

Page 23: SharePoint Saturday Cincinnati 2014 - CSOM

Get-Recap

• Loaded assemblies using: Import-SPOAssemblies

• Created context using New-SPOServiceContext

• Created a new Site usingNew-SPOWeb

• Retrieved Web usingGet-SPOWeb

• Set Properties with CSOM• Created a new List with

New-SPOList

Important!All of these

functions/commands are a part of

our custom PowerShell

Module! Not OOTB.

Page 24: SharePoint Saturday Cincinnati 2014 - CSOM

Get-Info –Type “Bonus”

• All of this works on-premises as well…– Just need to create ClientContext()

differently• Use the System.Net.NetworkCredential object

instead of Microsoft.SharePoint.Client.SharePointOnlineCredentials

• It is security trimmed, if you don’t have SP permissions to do this – you can’t…

• CSOM != SSOM– You do not have access to all of the same

methods and properties…

Page 25: SharePoint Saturday Cincinnati 2014 - CSOM

Q U E S T I O N S ?

Page 26: SharePoint Saturday Cincinnati 2014 - CSOM

Ryan DennisSenior SharePoint Consultant at Blue Chip Consulting Group

Recently published first book as a co-author

www.bluechip-llc.com

[email protected]

@SharePointRyan

/in/SharePointRyan

/SharePointRyanDotCom

www.sharepointryan.com

SP Geek Father

Drummer

Scripter Author

Husband

http://bit.ly/MMS13book


Recommended