SlideShare a Scribd company logo
PowerShell SharePointTalbott CrowellSPSBoston, September 25, 2010http://www.thirdm.com
Unix-like shellObject oriented.NETCommand lineScripting languageWhat is PowerShell?
Automated build and deployRapid prototypingExploring “What If” scenariosDeveloper onboardingAdministration automationWhy PowerShell for SharePoint?
When you want to make your team more agileAutomation, automation, automationWhen developing, your daily build is like the projects heartbeatPowerShell can be the pacemakerTestingUse the PowerShell scripts to stand up an environment for running testsWhen use PowerShell?
What do you know about a command line?DIRHow about$a = DIRWhat is $a?.NET Objectuse gm or get-member to query properitesArray$a[0]PowerShell Basics
PowerShell Basics$a = DIR$a | gmDatesDemo - Basics
Cmd, notepadPowerShell CommandWindows PowerShell Integrated Scripting Environment (ISE)Import-Module ServerManager;Add-WindowsFeaturePowerShell-ISE PowerGUIDownload from powergui.orgTools
# for commentVerb-Noun convention for commandletsWrite-Host “Hello World”Set-ExecutionPolicyUnrestricted.\scriptname to executeMore Basics
Comes with PowerShell CommandletsGet-SPSiteNew-SPSiteNew-SPWebIf you are running from standard PowerShellAdd-PSSnapinmicrosoft.sharepoint.powershell-ErrorActionSilentlyContinueSharePoint 2010
Get-SPSiteParameter: urlNew-SPSiteParameters: url, name, ownerAlias, templateNew-SPWebParameters: url, name, description, template…Other params: -AddToTopNav or -UseParentTopNav-AddToQuickLaunchCreate Site Collections and Sites
Your friend STSADM is still thereYou can call STSADM or any command line tool from PowerShellYou can write your own command line tools with .NETBetter yet, you can write your own PowerShell Commandlets!Inherit from Cmdletor PSCmdletGary Lapointe has WSS and MOSS Cmdlets!http://stsadm.blogspot.com/2009/02/downloads.htmlWhat about MOSS 2007 or WSS?
When creating non-persistent tasks (i.e. get info) use:SPCmdletWhen objects persist between commands, use:SPRemoveCmdletBaseSPNewCmdletBaseSPSetCmdletBaseSPGetCmdletBaseFor more info, see Gary Lapointe’s blog post:http://stsadm.blogspot.com/2009/10/creating-custom-sharepoint-2010-cmdlets.htmlCreating SharePoint 2010 Cmdlets
[void][System.Reflection.Assembly]::LoadWithPartialName(”Microsoft.SharePoint”)Load the assembly$SPSite = New-ObjectMicrosoft.SharePoint.SPSite($url)Reference to the site collection using SharePoint object modelDon’t forget to$SPSite.Dispose()Creating SharePoint Objects
Series of scripts to build your siteCleanup script to destroy siteEdit script, run cleanup, run script, view siteRepeatStrategy
Build2010.ps1Calls other scriptsBuild2010_site_structure.ps1Sets up the basic site structure and content typesBuild2010_upload_file.ps1Uploads sample files to the siteBuild2010_set_logo.ps1Adds site logoBuild2010_add_users.ps1Adds users to local machine and/or SharePoint groupsDemo – series of scripts
function Get-Theme([Microsoft.SharePoint.SPWeb]$SPWeb,[string]$themeName)Strong typed parametersReturns Microsoft.SharePoint.Utilities.ThmxThemeDefining functions
Upload FileTakes in 1 or more filesHas 3 blocksBeginProcessEndProcess is executed for each filegci 'C:\uploadfiles\Samples\Legal'  | .\build2010_upload_file.ps1 -Location "shared/legal" -DocLib "Documents" -ContentType "Document" -MetaDataField "Dept" -MetaDataValue "Legal"Iteration Style Scripts
How to: Build a SharePoint 2010 PowerShell Cmdlethttp://silverlight.sys-con.com/node/1370916Other References
Thank you. Questions?PowerShell SharePointTalbott CrowellThirdM.comhttp://talbottc.spaces.live.comTwitter: @talbott

More Related Content

What's hot (20)

PDF
10 things every developer should know about their database to run word press ...
Otto Kekäläinen
 
PDF
Firebase slide
Apaichon Punopas
 
PPTX
Cyansible
Alan Norton
 
PDF
Ruby on Rails Kickstart 101 & 102
Heng-Yi Wu
 
ODP
Drupal7
guest0b5da
 
PDF
Ansible testing
Scott van Kalken
 
PPTX
Troubleshooting Apache CloudStack at #ccceu14 by @jorizvl
Joris van Lieshout
 
PDF
Cialug August 2021
Andrew Denner
 
PPTX
Package Management on Windows with Chocolatey
Puppet
 
PDF
What makes me "Grunt"?
Fabien Doiron
 
PPTX
Setting up Kubernetes with tectonic
Vishal Biyani
 
PDF
Ansible and AWS
Peter Sankauskas
 
PDF
빈스톡 첫인상 with Git
AWSKRUG - AWS한국사용자모임
 
PPTX
Ansible: How to Get More Sleep and Require Less Coffee
Sarah Z
 
PDF
Tips and Tricks for Automating Windows with Chef
Chef Software, Inc.
 
PDF
Deploying PHP Applications with Ansible
Orestes Carracedo
 
PDF
Node intro
Vishal Sharma
 
PDF
Testing Ansible with Jenkins and Docker
Dennis Rowe
 
PDF
Docker in Production - IPC 15 München
Robert Lemke
 
PPTX
Basics of Ansible - Sahil Davawala
Sahil Davawala
 
10 things every developer should know about their database to run word press ...
Otto Kekäläinen
 
Firebase slide
Apaichon Punopas
 
Cyansible
Alan Norton
 
Ruby on Rails Kickstart 101 & 102
Heng-Yi Wu
 
Drupal7
guest0b5da
 
Ansible testing
Scott van Kalken
 
Troubleshooting Apache CloudStack at #ccceu14 by @jorizvl
Joris van Lieshout
 
Cialug August 2021
Andrew Denner
 
Package Management on Windows with Chocolatey
Puppet
 
What makes me "Grunt"?
Fabien Doiron
 
Setting up Kubernetes with tectonic
Vishal Biyani
 
Ansible and AWS
Peter Sankauskas
 
빈스톡 첫인상 with Git
AWSKRUG - AWS한국사용자모임
 
Ansible: How to Get More Sleep and Require Less Coffee
Sarah Z
 
Tips and Tricks for Automating Windows with Chef
Chef Software, Inc.
 
Deploying PHP Applications with Ansible
Orestes Carracedo
 
Node intro
Vishal Sharma
 
Testing Ansible with Jenkins and Docker
Dennis Rowe
 
Docker in Production - IPC 15 München
Robert Lemke
 
Basics of Ansible - Sahil Davawala
Sahil Davawala
 

Viewers also liked (7)

PPTX
Introduction to PowerShell for SharePoint - SharePointFest 2014 workshop
Michael Blumenthal (Microsoft MVP)
 
PPTX
Dogfood slides 2012
Ryan Dennis
 
PPTX
Funnel your Info down a new Path
Ryan Dennis
 
PPTX
DAYSPUG - Funnel your info down a new path
Ryan Dennis
 
PPTX
ScarePoint Saturday Spookinnati Slides
Ryan Dennis
 
PPTX
Build your SharePoint Internet Presence with PowerShell
Ryan Dennis
 
PPTX
Spsatx slides (widescreen)
Ryan Dennis
 
Introduction to PowerShell for SharePoint - SharePointFest 2014 workshop
Michael Blumenthal (Microsoft MVP)
 
Dogfood slides 2012
Ryan Dennis
 
Funnel your Info down a new Path
Ryan Dennis
 
DAYSPUG - Funnel your info down a new path
Ryan Dennis
 
ScarePoint Saturday Spookinnati Slides
Ryan Dennis
 
Build your SharePoint Internet Presence with PowerShell
Ryan Dennis
 
Spsatx slides (widescreen)
Ryan Dennis
 
Ad

Similar to Automating PowerShell with SharePoint (20)

PPTX
Introduction to PowerShell - Be a PowerShell Hero - SPFest workshop
Michael Blumenthal (Microsoft MVP)
 
PPTX
Intro to SharePoint + PowerShell
Ryan Dennis
 
PPTX
NZ Code Camp 2011 PowerShell + SharePoint
Nick Hadlee
 
PPTX
Introduction to PowerShell for SharePoint Admins and Developers - SharePoint ...
Michael Blumenthal (Microsoft MVP)
 
PPTX
Intro to PowerShell
Adam Preston
 
PPTX
Brian Jackett: Managing SharePoint 2010 Farms with Powershell
SharePoint Saturday NY
 
PPTX
Brian Jackett: Managing SharePoint 2010 Farms with Powershell
SharePoint Saturday NY
 
PPTX
Power shell for sp admins
Rick Taylor
 
PPTX
PowerShell Fundamentals for SharePoint
Sparkhound Inc.
 
PPTX
Using PowerShell for SharePoint 2013
Nikolas Charlebois-Laprade
 
PDF
Operacion Guinda 2
Red RADAR
 
PPTX
Introduction to PowerShell for SharePoint Admins and Developers
Michael Blumenthal (Microsoft MVP)
 
PPTX
Using Powershell to manage SharePoint
Craig Pilkenton
 
PDF
PowerShell for SharePoint Developers
Boulos Dib
 
PDF
Introduction to PowerShell
Boulos Dib
 
PPTX
Introduction to windows power shell in sharepoint 2010
Binh Nguyen
 
PPTX
Automating Your Enterprise Application Deployments With PowerShell by Geoff V...
SPTechCon
 
PPTX
Power shell basics in sharepoint 2010 - SharePoint Saturday Houston 2010
Corey Roth
 
PPTX
How to do everything with PowerShell
Juan Carlos Gonzalez
 
PPTX
PowerShell Basics for Office Apps and Servers
Greg McMurray
 
Introduction to PowerShell - Be a PowerShell Hero - SPFest workshop
Michael Blumenthal (Microsoft MVP)
 
Intro to SharePoint + PowerShell
Ryan Dennis
 
NZ Code Camp 2011 PowerShell + SharePoint
Nick Hadlee
 
Introduction to PowerShell for SharePoint Admins and Developers - SharePoint ...
Michael Blumenthal (Microsoft MVP)
 
Intro to PowerShell
Adam Preston
 
Brian Jackett: Managing SharePoint 2010 Farms with Powershell
SharePoint Saturday NY
 
Brian Jackett: Managing SharePoint 2010 Farms with Powershell
SharePoint Saturday NY
 
Power shell for sp admins
Rick Taylor
 
PowerShell Fundamentals for SharePoint
Sparkhound Inc.
 
Using PowerShell for SharePoint 2013
Nikolas Charlebois-Laprade
 
Operacion Guinda 2
Red RADAR
 
Introduction to PowerShell for SharePoint Admins and Developers
Michael Blumenthal (Microsoft MVP)
 
Using Powershell to manage SharePoint
Craig Pilkenton
 
PowerShell for SharePoint Developers
Boulos Dib
 
Introduction to PowerShell
Boulos Dib
 
Introduction to windows power shell in sharepoint 2010
Binh Nguyen
 
Automating Your Enterprise Application Deployments With PowerShell by Geoff V...
SPTechCon
 
Power shell basics in sharepoint 2010 - SharePoint Saturday Houston 2010
Corey Roth
 
How to do everything with PowerShell
Juan Carlos Gonzalez
 
PowerShell Basics for Office Apps and Servers
Greg McMurray
 
Ad

More from Talbott Crowell (19)

PPTX
Talbott's brief History of Computers for CollabDays Hamburg 2025
Talbott Crowell
 
PPTX
Top 7 mistakes
Talbott Crowell
 
PPTX
Top 3 Mistakes when Building
Talbott Crowell
 
PPTX
Building high performance and scalable share point applications
Talbott Crowell
 
PPTX
Road to the Cloud - Extending your reach with SharePoint and Office 365
Talbott Crowell
 
PPTX
Custom Development for SharePoint
Talbott Crowell
 
PPTX
Custom Development in SharePoint – What are my options now?
Talbott Crowell
 
PPTX
Developing a Provider Hosted SharePoint app
Talbott Crowell
 
PPTX
Developing a provider hosted share point app
Talbott Crowell
 
PPTX
Introduction to F# 3.0
Talbott Crowell
 
PPTX
PowerShell and SharePoint @spsnyc July 2012
Talbott Crowell
 
PPTX
PowerShell and SharePoint
Talbott Crowell
 
PPTX
Welcome to windows 8
Talbott Crowell
 
PPTX
Exploring SharePoint with F#
Talbott Crowell
 
PPTX
F# And Silverlight
Talbott Crowell
 
PPTX
SharePoint Saturday Boston 2010
Talbott Crowell
 
PPT
Automating SQL Server Database Creation for SharePoint
Talbott Crowell
 
PPTX
Introduction to F#
Talbott Crowell
 
PPTX
Architecting Solutions for the Manycore Future
Talbott Crowell
 
Talbott's brief History of Computers for CollabDays Hamburg 2025
Talbott Crowell
 
Top 7 mistakes
Talbott Crowell
 
Top 3 Mistakes when Building
Talbott Crowell
 
Building high performance and scalable share point applications
Talbott Crowell
 
Road to the Cloud - Extending your reach with SharePoint and Office 365
Talbott Crowell
 
Custom Development for SharePoint
Talbott Crowell
 
Custom Development in SharePoint – What are my options now?
Talbott Crowell
 
Developing a Provider Hosted SharePoint app
Talbott Crowell
 
Developing a provider hosted share point app
Talbott Crowell
 
Introduction to F# 3.0
Talbott Crowell
 
PowerShell and SharePoint @spsnyc July 2012
Talbott Crowell
 
PowerShell and SharePoint
Talbott Crowell
 
Welcome to windows 8
Talbott Crowell
 
Exploring SharePoint with F#
Talbott Crowell
 
F# And Silverlight
Talbott Crowell
 
SharePoint Saturday Boston 2010
Talbott Crowell
 
Automating SQL Server Database Creation for SharePoint
Talbott Crowell
 
Introduction to F#
Talbott Crowell
 
Architecting Solutions for the Manycore Future
Talbott Crowell
 

Automating PowerShell with SharePoint

  • 1. PowerShell SharePointTalbott CrowellSPSBoston, September 25, 2010http://www.thirdm.com
  • 2. Unix-like shellObject oriented.NETCommand lineScripting languageWhat is PowerShell?
  • 3. Automated build and deployRapid prototypingExploring “What If” scenariosDeveloper onboardingAdministration automationWhy PowerShell for SharePoint?
  • 4. When you want to make your team more agileAutomation, automation, automationWhen developing, your daily build is like the projects heartbeatPowerShell can be the pacemakerTestingUse the PowerShell scripts to stand up an environment for running testsWhen use PowerShell?
  • 5. What do you know about a command line?DIRHow about$a = DIRWhat is $a?.NET Objectuse gm or get-member to query properitesArray$a[0]PowerShell Basics
  • 6. PowerShell Basics$a = DIR$a | gmDatesDemo - Basics
  • 7. Cmd, notepadPowerShell CommandWindows PowerShell Integrated Scripting Environment (ISE)Import-Module ServerManager;Add-WindowsFeaturePowerShell-ISE PowerGUIDownload from powergui.orgTools
  • 8. # for commentVerb-Noun convention for commandletsWrite-Host “Hello World”Set-ExecutionPolicyUnrestricted.\scriptname to executeMore Basics
  • 9. Comes with PowerShell CommandletsGet-SPSiteNew-SPSiteNew-SPWebIf you are running from standard PowerShellAdd-PSSnapinmicrosoft.sharepoint.powershell-ErrorActionSilentlyContinueSharePoint 2010
  • 10. Get-SPSiteParameter: urlNew-SPSiteParameters: url, name, ownerAlias, templateNew-SPWebParameters: url, name, description, template…Other params: -AddToTopNav or -UseParentTopNav-AddToQuickLaunchCreate Site Collections and Sites
  • 11. Your friend STSADM is still thereYou can call STSADM or any command line tool from PowerShellYou can write your own command line tools with .NETBetter yet, you can write your own PowerShell Commandlets!Inherit from Cmdletor PSCmdletGary Lapointe has WSS and MOSS Cmdlets!http://stsadm.blogspot.com/2009/02/downloads.htmlWhat about MOSS 2007 or WSS?
  • 12. When creating non-persistent tasks (i.e. get info) use:SPCmdletWhen objects persist between commands, use:SPRemoveCmdletBaseSPNewCmdletBaseSPSetCmdletBaseSPGetCmdletBaseFor more info, see Gary Lapointe’s blog post:http://stsadm.blogspot.com/2009/10/creating-custom-sharepoint-2010-cmdlets.htmlCreating SharePoint 2010 Cmdlets
  • 13. [void][System.Reflection.Assembly]::LoadWithPartialName(”Microsoft.SharePoint”)Load the assembly$SPSite = New-ObjectMicrosoft.SharePoint.SPSite($url)Reference to the site collection using SharePoint object modelDon’t forget to$SPSite.Dispose()Creating SharePoint Objects
  • 14. Series of scripts to build your siteCleanup script to destroy siteEdit script, run cleanup, run script, view siteRepeatStrategy
  • 15. Build2010.ps1Calls other scriptsBuild2010_site_structure.ps1Sets up the basic site structure and content typesBuild2010_upload_file.ps1Uploads sample files to the siteBuild2010_set_logo.ps1Adds site logoBuild2010_add_users.ps1Adds users to local machine and/or SharePoint groupsDemo – series of scripts
  • 16. function Get-Theme([Microsoft.SharePoint.SPWeb]$SPWeb,[string]$themeName)Strong typed parametersReturns Microsoft.SharePoint.Utilities.ThmxThemeDefining functions
  • 17. Upload FileTakes in 1 or more filesHas 3 blocksBeginProcessEndProcess is executed for each filegci 'C:\uploadfiles\Samples\Legal' | .\build2010_upload_file.ps1 -Location "shared/legal" -DocLib "Documents" -ContentType "Document" -MetaDataField "Dept" -MetaDataValue "Legal"Iteration Style Scripts
  • 18. How to: Build a SharePoint 2010 PowerShell Cmdlethttp://silverlight.sys-con.com/node/1370916Other References
  • 19. Thank you. Questions?PowerShell SharePointTalbott CrowellThirdM.comhttp://talbottc.spaces.live.comTwitter: @talbott