KEMBAR78
Managing SharePoint Anywhere with Windows PowerShell | PPTX
Managing SharePoint Anywhere with 
Windows PowerShell 
Ryan Dennis
Ryan Dennis 
Senior SharePoint Consultant at Blue Chip Consulting Group 
Recently published first book as a co-author 
SP Geek Father 
www.bluechip-llc.com Drummer Husband 
ryan.dennis@bluechip-llc.com 
@SharePointRyan 
/in/SharePointRyan 
Dog Lover Author 
/SharePointRyanDotCom 
www.sharepointryan.com 
http://bit.ly/MMS13book
Archie the Corgi
Ask Our Experts! 
• Visit the Blue Chip booth to 
chat with one of our Expert 
Consultants 
• Drop us your business card, 
and we’ll help you solve your 
business problem and you 
might win an XBOX One** 
• Our resident SharePoint 
MCM/MVP is here all day, 
Monday & Tuesday* 
• Visit our other sessions in 
the SharePoint & PowerShell 
tracks! 
*Except when presenting 
**Drawing Tuesday. 
Blue Chip Featured Expert 
Paul Stork 
@PStork 
Paul is a Microsoft 
SharePoint MVP and 
MCM who works as 
Principal Architect at Blue Chip 
Consulting Group. An author and/or 
contributor on several SharePoint books, 
Paul is a well-known contributor to the 
SharePoint community.
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
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
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!
Get-Command & Get-Help 
• Use Get-Command to see available 
commands 
Get-Command –Module 
Microsoft.SharePoint.PowerShell 
Get-Command –Module 
Microsoft.Online.SharePoint.PowerShell 
• Use Get-Help <CmdletName> to get 
help information for a cmdlet 
Quick Tip! 
Add Help to your 
scripts and 
functions!
Get-Command –Type “SharePoint” 
• 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… 
Opportunity! 
Write our own scripts 
and functions!
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!
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 cmdlet 
Disclaimer! 
This is NOT a SharePoint 
demo, just a general 
PowerShell demo!
D E M O 
Write-Message
Get-Recap 
• Reviewed Write-Message function… 
• Created output using all Write* types 
• Saw the behavior of –Verbose and –Debug 
switches 
• Had some fun…
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.
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.
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
Get-Intro –Topic “SharePoint CSOM” 
• Add the following Assemblies 
– Microsoft.SharePoint.Client.dll 
– Microsoft.SharePoint.Client.Runtime.dll 
• Create a ClientContext variable 
• Call the Load() and ExecuteQuery() 
methods 
• Once context is created, get and set 
properties… For help on writing 
CSOM, see 
http://bit.ly/MsdnCsom
D E M O 
SharePoint Online
Get-Recap 
• Loaded assemblies using: 
Import-SPOAssemblies 
• Created context using 
New-SPOServiceContext 
• Created a new Site using 
New-SPOWeb 
• Retrieved Web using 
Get-SPOWeb 
• Set Properties with 
Set-SPOWebProperties 
Important! 
All of these 
functions/commands 
are a part of our 
custom PowerShell 
Module! Not OOTB.
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…
Q U E S T I O N S ?
Ryan Dennis 
Senior SharePoint Consultant at Blue Chip Consulting Group 
Recently published first book as a co-author 
SP Geek Father 
www.bluechip-llc.com 
Drummer Husband ryan.dennis@bluechip-llc.com 
@SharePointRyan 
/in/SharePointRyan 
Dog Lover Author 
/SharePointRyanDotCom 
www.sharepointryan.com 
http://bit.ly/MMS13book

Managing SharePoint Anywhere with Windows PowerShell

  • 1.
    Managing SharePoint Anywherewith Windows PowerShell Ryan Dennis
  • 2.
    Ryan Dennis SeniorSharePoint Consultant at Blue Chip Consulting Group Recently published first book as a co-author SP Geek Father www.bluechip-llc.com Drummer Husband ryan.dennis@bluechip-llc.com @SharePointRyan /in/SharePointRyan Dog Lover Author /SharePointRyanDotCom www.sharepointryan.com http://bit.ly/MMS13book
  • 3.
  • 4.
    Ask Our Experts! • Visit the Blue Chip booth to chat with one of our Expert Consultants • Drop us your business card, and we’ll help you solve your business problem and you might win an XBOX One** • Our resident SharePoint MCM/MVP is here all day, Monday & Tuesday* • Visit our other sessions in the SharePoint & PowerShell tracks! *Except when presenting **Drawing Tuesday. Blue Chip Featured Expert Paul Stork @PStork Paul is a Microsoft SharePoint MVP and MCM who works as Principal Architect at Blue Chip Consulting Group. An author and/or contributor on several SharePoint books, Paul is a well-known contributor to the SharePoint community.
  • 5.
    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
  • 6.
    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
  • 7.
    Verb-Noun PowerShell usesa 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!
  • 8.
    Get-Command & Get-Help • Use Get-Command to see available commands Get-Command –Module Microsoft.SharePoint.PowerShell Get-Command –Module Microsoft.Online.SharePoint.PowerShell • Use Get-Help <CmdletName> to get help information for a cmdlet Quick Tip! Add Help to your scripts and functions!
  • 9.
    Get-Command –Type “SharePoint” • 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… Opportunity! Write our own scripts and functions!
  • 10.
    Get-Help About_Functions_Advanced …allowyou 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!
  • 11.
    New-Function –Name “OurFirst 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 cmdlet Disclaimer! This is NOT a SharePoint demo, just a general PowerShell demo!
  • 12.
    D E MO Write-Message
  • 13.
    Get-Recap • ReviewedWrite-Message function… • Created output using all Write* types • Saw the behavior of –Verbose and –Debug switches • Had some fun…
  • 14.
    Get-Info “SP PowerShellOn-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.
  • 15.
    Get-Info “SP PowerShellO365” • 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.
  • 16.
    Get-Started -with “SPOnline 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
  • 17.
    Get-Intro –Topic “SharePointCSOM” • Add the following Assemblies – Microsoft.SharePoint.Client.dll – Microsoft.SharePoint.Client.Runtime.dll • Create a ClientContext variable • Call the Load() and ExecuteQuery() methods • Once context is created, get and set properties… For help on writing CSOM, see http://bit.ly/MsdnCsom
  • 18.
    D E MO SharePoint Online
  • 19.
    Get-Recap • Loadedassemblies using: Import-SPOAssemblies • Created context using New-SPOServiceContext • Created a new Site using New-SPOWeb • Retrieved Web using Get-SPOWeb • Set Properties with Set-SPOWebProperties Important! All of these functions/commands are a part of our custom PowerShell Module! Not OOTB.
  • 20.
    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…
  • 21.
    Q U ES T I O N S ?
  • 22.
    Ryan Dennis SeniorSharePoint Consultant at Blue Chip Consulting Group Recently published first book as a co-author SP Geek Father www.bluechip-llc.com Drummer Husband ryan.dennis@bluechip-llc.com @SharePointRyan /in/SharePointRyan Dog Lover Author /SharePointRyanDotCom www.sharepointryan.com http://bit.ly/MMS13book

Editor's Notes

  • #13 Go to the BI Center Excel Services Visio Services
  • #19 Go to the BI Center Excel Services Visio Services
  • #22 -Show an existing discussion with multiple replies -Create a new discussion -