SlideShare uma empresa Scribd logo
1 de 19
PowerShell SharePoint Talbott Crowell SPSBoston, September 25, 2010http://www.thirdm.com
Unix-like shell Object oriented .NET Command line Scripting language What is PowerShell?
Automated build and deploy Rapid prototyping Exploring “What If” scenarios Developer onboarding Administration automation Why PowerShell for SharePoint?
When you want to make your team more agile Automation, automation, automation When developing, your daily build is like the projects heartbeat PowerShell can be the pacemaker Testing Use the PowerShell scripts to stand up an environment for running tests When use PowerShell?
What do you know about a command line? DIR How about $a = DIR What is $a? .NET Object use gm or get-member to query properites Array $a[0] PowerShell Basics
PowerShell Basics $a = DIR $a | gm Dates Demo - Basics
Cmd, notepad PowerShell Command Windows PowerShell Integrated Scripting Environment (ISE) Import-Module ServerManager; Add-WindowsFeaturePowerShell-ISE  PowerGUI Download from powergui.org Tools
# for comment Verb-Noun convention for commandlets Write-Host “Hello World” Set-ExecutionPolicyUnrestricted .criptname to execute More Basics
Comes with PowerShell Commandlets Get-SPSite New-SPSite New-SPWeb If you are running from standard PowerShell Add-PSSnapinmicrosoft.sharepoint.powershell-ErrorActionSilentlyContinue SharePoint 2010
Get-SPSite Parameter: url New-SPSite Parameters: url, name, ownerAlias, template New-SPWeb Parameters: url, name, description, template… Other params:  -AddToTopNav or -UseParentTopNav -AddToQuickLaunch Create Site Collections and Sites
Your friend STSADM is still there You can call STSADM or any command line tool from PowerShell You can write your own command line tools with .NET Better yet, you can write your own PowerShell Commandlets! Inherit from Cmdletor PSCmdlet Gary Lapointe has WSS and MOSS Cmdlets! http://stsadm.blogspot.com/2009/02/downloads.html What about MOSS 2007 or WSS?
When creating non-persistent tasks (i.e. get info) use: SPCmdlet When objects persist between commands, use: SPRemoveCmdletBase SPNewCmdletBase SPSetCmdletBase SPGetCmdletBase For more info, see Gary Lapointe’s blog post: http://stsadm.blogspot.com/2009/10/creating-custom-sharepoint-2010-cmdlets.html Creating 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 model Don’t forget to $SPSite.Dispose() Creating SharePoint Objects
Series of scripts to build your site Cleanup script to destroy site Edit script, run cleanup, run script, view site Repeat Strategy
Build2010.ps1 Calls other scripts Build2010_site_structure.ps1 Sets up the basic site structure and content types Build2010_upload_file.ps1 Uploads sample files to the site Build2010_set_logo.ps1 Adds site logo Build2010_add_users.ps1 Adds users to local machine and/or SharePoint groups Demo – series of scripts
function Get-Theme([Microsoft.SharePoint.SPWeb]$SPWeb,[string]$themeName) Strong typed parameters Returns Microsoft.SharePoint.Utilities.ThmxTheme Defining functions
Upload File Takes in 1 or more files Has 3 blocks Begin Process End Process is executed for each file gci 'C:ploadfilesamplesegal'  | .uild2010_upload_file.ps1 -Location "shared/legal" -DocLib "Documents" -ContentType "Document" -MetaDataField "Dept" -MetaDataValue "Legal" Iteration Style Scripts
How to: Build a SharePoint 2010 PowerShell Cmdlet http://silverlight.sys-con.com/node/1370916 Other References
Thank you. Questions?PowerShell SharePoint Talbott Crowell ThirdM.com http://talbottc.spaces.live.com Twitter: @talbott

Mais conteúdo relacionado

Mais procurados

10 things every developer should know about their database to run word press ...
10 things every developer should know about their database to run word press ...10 things every developer should know about their database to run word press ...
10 things every developer should know about their database to run word press ...Otto Kekäläinen
 
Ruby on Rails Kickstart 101 & 102
Ruby on Rails Kickstart 101 & 102Ruby on Rails Kickstart 101 & 102
Ruby on Rails Kickstart 101 & 102Heng-Yi Wu
 
Troubleshooting Apache CloudStack at #ccceu14 by @jorizvl
Troubleshooting Apache CloudStack at #ccceu14 by @jorizvlTroubleshooting Apache CloudStack at #ccceu14 by @jorizvl
Troubleshooting Apache CloudStack at #ccceu14 by @jorizvlJoris van Lieshout
 
Package Management on Windows with Chocolatey
Package Management on Windows with ChocolateyPackage Management on Windows with Chocolatey
Package Management on Windows with ChocolateyPuppet
 
What makes me "Grunt"?
What makes me "Grunt"? What makes me "Grunt"?
What makes me "Grunt"? Fabien Doiron
 
Setting up Kubernetes with tectonic
Setting up Kubernetes with tectonicSetting up Kubernetes with tectonic
Setting up Kubernetes with tectonicVishal Biyani
 
Ansible: How to Get More Sleep and Require Less Coffee
Ansible: How to Get More Sleep and Require Less CoffeeAnsible: How to Get More Sleep and Require Less Coffee
Ansible: How to Get More Sleep and Require Less CoffeeSarah Z
 
Tips and Tricks for Automating Windows with Chef
Tips and Tricks for Automating Windows with ChefTips and Tricks for Automating Windows with Chef
Tips and Tricks for Automating Windows with ChefChef Software, Inc.
 
Deploying PHP Applications with Ansible
Deploying PHP Applications with AnsibleDeploying PHP Applications with Ansible
Deploying PHP Applications with AnsibleOrestes Carracedo
 
Testing Ansible with Jenkins and Docker
Testing Ansible with Jenkins and DockerTesting Ansible with Jenkins and Docker
Testing Ansible with Jenkins and DockerDennis Rowe
 
Docker in Production - IPC 15 München
Docker in Production - IPC 15 MünchenDocker in Production - IPC 15 München
Docker in Production - IPC 15 MünchenRobert Lemke
 
Basics of Ansible - Sahil Davawala
Basics of Ansible - Sahil DavawalaBasics of Ansible - Sahil Davawala
Basics of Ansible - Sahil DavawalaSahil Davawala
 

Mais procurados (20)

10 things every developer should know about their database to run word press ...
10 things every developer should know about their database to run word press ...10 things every developer should know about their database to run word press ...
10 things every developer should know about their database to run word press ...
 
Firebase slide
Firebase slideFirebase slide
Firebase slide
 
Cyansible
CyansibleCyansible
Cyansible
 
Ruby on Rails Kickstart 101 & 102
Ruby on Rails Kickstart 101 & 102Ruby on Rails Kickstart 101 & 102
Ruby on Rails Kickstart 101 & 102
 
Drupal7
Drupal7Drupal7
Drupal7
 
Ansible testing
Ansible   testingAnsible   testing
Ansible testing
 
Troubleshooting Apache CloudStack at #ccceu14 by @jorizvl
Troubleshooting Apache CloudStack at #ccceu14 by @jorizvlTroubleshooting Apache CloudStack at #ccceu14 by @jorizvl
Troubleshooting Apache CloudStack at #ccceu14 by @jorizvl
 
Cialug August 2021
Cialug August 2021Cialug August 2021
Cialug August 2021
 
Package Management on Windows with Chocolatey
Package Management on Windows with ChocolateyPackage Management on Windows with Chocolatey
Package Management on Windows with Chocolatey
 
What makes me "Grunt"?
What makes me "Grunt"? What makes me "Grunt"?
What makes me "Grunt"?
 
Setting up Kubernetes with tectonic
Setting up Kubernetes with tectonicSetting up Kubernetes with tectonic
Setting up Kubernetes with tectonic
 
Ansible and AWS
Ansible and AWSAnsible and AWS
Ansible and AWS
 
빈스톡 첫인상 with Git
빈스톡 첫인상 with Git빈스톡 첫인상 with Git
빈스톡 첫인상 with Git
 
Ansible: How to Get More Sleep and Require Less Coffee
Ansible: How to Get More Sleep and Require Less CoffeeAnsible: How to Get More Sleep and Require Less Coffee
Ansible: How to Get More Sleep and Require Less Coffee
 
Tips and Tricks for Automating Windows with Chef
Tips and Tricks for Automating Windows with ChefTips and Tricks for Automating Windows with Chef
Tips and Tricks for Automating Windows with Chef
 
Deploying PHP Applications with Ansible
Deploying PHP Applications with AnsibleDeploying PHP Applications with Ansible
Deploying PHP Applications with Ansible
 
Node intro
Node introNode intro
Node intro
 
Testing Ansible with Jenkins and Docker
Testing Ansible with Jenkins and DockerTesting Ansible with Jenkins and Docker
Testing Ansible with Jenkins and Docker
 
Docker in Production - IPC 15 München
Docker in Production - IPC 15 MünchenDocker in Production - IPC 15 München
Docker in Production - IPC 15 München
 
Basics of Ansible - Sahil Davawala
Basics of Ansible - Sahil DavawalaBasics of Ansible - Sahil Davawala
Basics of Ansible - Sahil Davawala
 

Destaque

Introduction to PowerShell for SharePoint - SharePointFest 2014 workshop
Introduction to PowerShell for SharePoint - SharePointFest 2014 workshopIntroduction to PowerShell for SharePoint - SharePointFest 2014 workshop
Introduction to PowerShell for SharePoint - SharePointFest 2014 workshopMichael Blumenthal (Microsoft MVP)
 
Dogfood slides 2012
Dogfood slides 2012Dogfood slides 2012
Dogfood slides 2012Ryan Dennis
 
Funnel your Info down a new Path
Funnel your Info down a new PathFunnel your Info down a new Path
Funnel your Info down a new PathRyan Dennis
 
DAYSPUG - Funnel your info down a new path
DAYSPUG - Funnel your info down a new pathDAYSPUG - Funnel your info down a new path
DAYSPUG - Funnel your info down a new pathRyan Dennis
 
ScarePoint Saturday Spookinnati Slides
ScarePoint Saturday Spookinnati SlidesScarePoint Saturday Spookinnati Slides
ScarePoint Saturday Spookinnati SlidesRyan Dennis
 
Build your SharePoint Internet Presence with PowerShell
Build your SharePoint Internet Presence with PowerShellBuild your SharePoint Internet Presence with PowerShell
Build your SharePoint Internet Presence with PowerShellRyan Dennis
 
Spsatx slides (widescreen)
Spsatx slides (widescreen)Spsatx slides (widescreen)
Spsatx slides (widescreen)Ryan Dennis
 

Destaque (7)

Introduction to PowerShell for SharePoint - SharePointFest 2014 workshop
Introduction to PowerShell for SharePoint - SharePointFest 2014 workshopIntroduction to PowerShell for SharePoint - SharePointFest 2014 workshop
Introduction to PowerShell for SharePoint - SharePointFest 2014 workshop
 
Dogfood slides 2012
Dogfood slides 2012Dogfood slides 2012
Dogfood slides 2012
 
Funnel your Info down a new Path
Funnel your Info down a new PathFunnel your Info down a new Path
Funnel your Info down a new Path
 
DAYSPUG - Funnel your info down a new path
DAYSPUG - Funnel your info down a new pathDAYSPUG - Funnel your info down a new path
DAYSPUG - Funnel your info down a new path
 
ScarePoint Saturday Spookinnati Slides
ScarePoint Saturday Spookinnati SlidesScarePoint Saturday Spookinnati Slides
ScarePoint Saturday Spookinnati Slides
 
Build your SharePoint Internet Presence with PowerShell
Build your SharePoint Internet Presence with PowerShellBuild your SharePoint Internet Presence with PowerShell
Build your SharePoint Internet Presence with PowerShell
 
Spsatx slides (widescreen)
Spsatx slides (widescreen)Spsatx slides (widescreen)
Spsatx slides (widescreen)
 

Semelhante a Automating PowerShell with SharePoint

PowerShell for SharePoint Developers
PowerShell for SharePoint DevelopersPowerShell for SharePoint Developers
PowerShell for SharePoint DevelopersBoulos Dib
 
Brian Jackett: Managing SharePoint 2010 Farms with Powershell
Brian Jackett: Managing SharePoint 2010 Farms with PowershellBrian Jackett: Managing SharePoint 2010 Farms with Powershell
Brian Jackett: Managing SharePoint 2010 Farms with PowershellSharePoint Saturday NY
 
Brian Jackett: Managing SharePoint 2010 Farms with Powershell
Brian Jackett: Managing SharePoint 2010 Farms with PowershellBrian Jackett: Managing SharePoint 2010 Farms with Powershell
Brian Jackett: Managing SharePoint 2010 Farms with PowershellSharePoint Saturday NY
 
Intro to PowerShell
Intro to PowerShellIntro to PowerShell
Intro to PowerShellAdam Preston
 
SPugPt Meeting 35: Manage govern and drive adoption of share point online wit...
SPugPt Meeting 35: Manage govern and drive adoption of share point online wit...SPugPt Meeting 35: Manage govern and drive adoption of share point online wit...
SPugPt Meeting 35: Manage govern and drive adoption of share point online wit...Comunidade Portuguesa de SharePoiint
 
Introduction to windows power shell in sharepoint 2010
Introduction to windows power shell in sharepoint 2010Introduction to windows power shell in sharepoint 2010
Introduction to windows power shell in sharepoint 2010Binh Nguyen
 
Introduction to PowerShell
Introduction to PowerShellIntroduction to PowerShell
Introduction to PowerShellBoulos Dib
 
Windows PowerShell - Billings .NET User Group - August 2009
Windows PowerShell - Billings .NET User Group - August 2009Windows PowerShell - Billings .NET User Group - August 2009
Windows PowerShell - Billings .NET User Group - August 2009John Clayton
 
Automating Your Enterprise Application Deployments with PowerShell
Automating Your Enterprise Application Deployments with PowerShellAutomating Your Enterprise Application Deployments with PowerShell
Automating Your Enterprise Application Deployments with PowerShellGeoff Varosky
 
Sql Server & PowerShell
Sql Server & PowerShellSql Server & PowerShell
Sql Server & PowerShellAaron Shilo
 
Automating Your Enterprise Application Deployments With PowerShell by Geoff V...
Automating Your Enterprise Application Deployments With PowerShell by Geoff V...Automating Your Enterprise Application Deployments With PowerShell by Geoff V...
Automating Your Enterprise Application Deployments With PowerShell by Geoff V...SPTechCon
 
Introduction to Powershell Version 5
Introduction to Powershell Version 5Introduction to Powershell Version 5
Introduction to Powershell Version 5Nishtha Kesarwani
 
Introduction to PowerShell - Be a PowerShell Hero - SPFest workshop
Introduction to PowerShell - Be a PowerShell Hero - SPFest workshopIntroduction to PowerShell - Be a PowerShell Hero - SPFest workshop
Introduction to PowerShell - Be a PowerShell Hero - SPFest workshopMichael Blumenthal (Microsoft MVP)
 
Getting Started With PowerShell Scripting
Getting Started With PowerShell ScriptingGetting Started With PowerShell Scripting
Getting Started With PowerShell ScriptingRavikanth Chaganti
 
Powershell Seminar @ ITWorx CuttingEdge Club
Powershell Seminar @ ITWorx CuttingEdge ClubPowershell Seminar @ ITWorx CuttingEdge Club
Powershell Seminar @ ITWorx CuttingEdge ClubEssam Salah
 
SharePoint for the .NET Developer
SharePoint for the .NET DeveloperSharePoint for the .NET Developer
SharePoint for the .NET DeveloperJohn Calvert
 
Power shell training
Power shell trainingPower shell training
Power shell trainingDavid Brabant
 
SPSToronto 2015 - Managing Office365 with PowerShell and CSOM
SPSToronto 2015 - Managing Office365 with PowerShell and CSOMSPSToronto 2015 - Managing Office365 with PowerShell and CSOM
SPSToronto 2015 - Managing Office365 with PowerShell and CSOMamitvasu
 

Semelhante a Automating PowerShell with SharePoint (20)

PowerShell for SharePoint Developers
PowerShell for SharePoint DevelopersPowerShell for SharePoint Developers
PowerShell for SharePoint Developers
 
Brian Jackett: Managing SharePoint 2010 Farms with Powershell
Brian Jackett: Managing SharePoint 2010 Farms with PowershellBrian Jackett: Managing SharePoint 2010 Farms with Powershell
Brian Jackett: Managing SharePoint 2010 Farms with Powershell
 
Brian Jackett: Managing SharePoint 2010 Farms with Powershell
Brian Jackett: Managing SharePoint 2010 Farms with PowershellBrian Jackett: Managing SharePoint 2010 Farms with Powershell
Brian Jackett: Managing SharePoint 2010 Farms with Powershell
 
Intro to PowerShell
Intro to PowerShellIntro to PowerShell
Intro to PowerShell
 
SPugPt Meeting 35: Manage govern and drive adoption of share point online wit...
SPugPt Meeting 35: Manage govern and drive adoption of share point online wit...SPugPt Meeting 35: Manage govern and drive adoption of share point online wit...
SPugPt Meeting 35: Manage govern and drive adoption of share point online wit...
 
Introduction to windows power shell in sharepoint 2010
Introduction to windows power shell in sharepoint 2010Introduction to windows power shell in sharepoint 2010
Introduction to windows power shell in sharepoint 2010
 
Introduction to PowerShell
Introduction to PowerShellIntroduction to PowerShell
Introduction to PowerShell
 
Windows PowerShell - Billings .NET User Group - August 2009
Windows PowerShell - Billings .NET User Group - August 2009Windows PowerShell - Billings .NET User Group - August 2009
Windows PowerShell - Billings .NET User Group - August 2009
 
Automating Your Enterprise Application Deployments with PowerShell
Automating Your Enterprise Application Deployments with PowerShellAutomating Your Enterprise Application Deployments with PowerShell
Automating Your Enterprise Application Deployments with PowerShell
 
Sql Server & PowerShell
Sql Server & PowerShellSql Server & PowerShell
Sql Server & PowerShell
 
Automating Your Enterprise Application Deployments With PowerShell by Geoff V...
Automating Your Enterprise Application Deployments With PowerShell by Geoff V...Automating Your Enterprise Application Deployments With PowerShell by Geoff V...
Automating Your Enterprise Application Deployments With PowerShell by Geoff V...
 
Introduction to Powershell Version 5
Introduction to Powershell Version 5Introduction to Powershell Version 5
Introduction to Powershell Version 5
 
Introduction to PowerShell - Be a PowerShell Hero - SPFest workshop
Introduction to PowerShell - Be a PowerShell Hero - SPFest workshopIntroduction to PowerShell - Be a PowerShell Hero - SPFest workshop
Introduction to PowerShell - Be a PowerShell Hero - SPFest workshop
 
Getting Started With PowerShell Scripting
Getting Started With PowerShell ScriptingGetting Started With PowerShell Scripting
Getting Started With PowerShell Scripting
 
Powershell Seminar @ ITWorx CuttingEdge Club
Powershell Seminar @ ITWorx CuttingEdge ClubPowershell Seminar @ ITWorx CuttingEdge Club
Powershell Seminar @ ITWorx CuttingEdge Club
 
SharePoint for the .NET Developer
SharePoint for the .NET DeveloperSharePoint for the .NET Developer
SharePoint for the .NET Developer
 
No-script PowerShell v2
No-script PowerShell v2No-script PowerShell v2
No-script PowerShell v2
 
Power shell
Power shellPower shell
Power shell
 
Power shell training
Power shell trainingPower shell training
Power shell training
 
SPSToronto 2015 - Managing Office365 with PowerShell and CSOM
SPSToronto 2015 - Managing Office365 with PowerShell and CSOMSPSToronto 2015 - Managing Office365 with PowerShell and CSOM
SPSToronto 2015 - Managing Office365 with PowerShell and CSOM
 

Mais de Talbott Crowell

Top 3 Mistakes when Building
Top 3 Mistakes when BuildingTop 3 Mistakes when Building
Top 3 Mistakes when BuildingTalbott Crowell
 
Building high performance and scalable share point applications
Building high performance and scalable share point applicationsBuilding high performance and scalable share point applications
Building high performance and scalable share point applicationsTalbott Crowell
 
Road to the Cloud - Extending your reach with SharePoint and Office 365
Road to the Cloud - Extending your reach with SharePoint and Office 365Road to the Cloud - Extending your reach with SharePoint and Office 365
Road to the Cloud - Extending your reach with SharePoint and Office 365Talbott Crowell
 
Custom Development for SharePoint
Custom Development for SharePointCustom Development for SharePoint
Custom Development for SharePointTalbott Crowell
 
Custom Development in SharePoint – What are my options now?
Custom Development in SharePoint – What are my options now?Custom Development in SharePoint – What are my options now?
Custom Development in SharePoint – What are my options now?Talbott Crowell
 
Developing a Provider Hosted SharePoint app
Developing a Provider Hosted SharePoint appDeveloping a Provider Hosted SharePoint app
Developing a Provider Hosted SharePoint appTalbott Crowell
 
Developing a provider hosted share point app
Developing a provider hosted share point appDeveloping a provider hosted share point app
Developing a provider hosted share point appTalbott Crowell
 
PowerShell and SharePoint @spsnyc July 2012
PowerShell and SharePoint @spsnyc July 2012PowerShell and SharePoint @spsnyc July 2012
PowerShell and SharePoint @spsnyc July 2012Talbott Crowell
 
PowerShell and SharePoint
PowerShell and SharePointPowerShell and SharePoint
PowerShell and SharePointTalbott Crowell
 
Exploring SharePoint with F#
Exploring SharePoint with F#Exploring SharePoint with F#
Exploring SharePoint with F#Talbott Crowell
 
SharePoint Saturday Boston 2010
SharePoint Saturday Boston 2010SharePoint Saturday Boston 2010
SharePoint Saturday Boston 2010Talbott Crowell
 
Automating SQL Server Database Creation for SharePoint
Automating SQL Server Database Creation for SharePointAutomating SQL Server Database Creation for SharePoint
Automating SQL Server Database Creation for SharePointTalbott Crowell
 
Architecting Solutions for the Manycore Future
Architecting Solutions for the Manycore FutureArchitecting Solutions for the Manycore Future
Architecting Solutions for the Manycore FutureTalbott Crowell
 

Mais de Talbott Crowell (18)

Top 7 mistakes
Top 7 mistakesTop 7 mistakes
Top 7 mistakes
 
Top 3 Mistakes when Building
Top 3 Mistakes when BuildingTop 3 Mistakes when Building
Top 3 Mistakes when Building
 
Building high performance and scalable share point applications
Building high performance and scalable share point applicationsBuilding high performance and scalable share point applications
Building high performance and scalable share point applications
 
Road to the Cloud - Extending your reach with SharePoint and Office 365
Road to the Cloud - Extending your reach with SharePoint and Office 365Road to the Cloud - Extending your reach with SharePoint and Office 365
Road to the Cloud - Extending your reach with SharePoint and Office 365
 
Custom Development for SharePoint
Custom Development for SharePointCustom Development for SharePoint
Custom Development for SharePoint
 
Custom Development in SharePoint – What are my options now?
Custom Development in SharePoint – What are my options now?Custom Development in SharePoint – What are my options now?
Custom Development in SharePoint – What are my options now?
 
Developing a Provider Hosted SharePoint app
Developing a Provider Hosted SharePoint appDeveloping a Provider Hosted SharePoint app
Developing a Provider Hosted SharePoint app
 
Developing a provider hosted share point app
Developing a provider hosted share point appDeveloping a provider hosted share point app
Developing a provider hosted share point app
 
Introduction to F# 3.0
Introduction to F# 3.0Introduction to F# 3.0
Introduction to F# 3.0
 
PowerShell and SharePoint @spsnyc July 2012
PowerShell and SharePoint @spsnyc July 2012PowerShell and SharePoint @spsnyc July 2012
PowerShell and SharePoint @spsnyc July 2012
 
PowerShell and SharePoint
PowerShell and SharePointPowerShell and SharePoint
PowerShell and SharePoint
 
Welcome to windows 8
Welcome to windows 8Welcome to windows 8
Welcome to windows 8
 
Exploring SharePoint with F#
Exploring SharePoint with F#Exploring SharePoint with F#
Exploring SharePoint with F#
 
F# And Silverlight
F# And SilverlightF# And Silverlight
F# And Silverlight
 
SharePoint Saturday Boston 2010
SharePoint Saturday Boston 2010SharePoint Saturday Boston 2010
SharePoint Saturday Boston 2010
 
Automating SQL Server Database Creation for SharePoint
Automating SQL Server Database Creation for SharePointAutomating SQL Server Database Creation for SharePoint
Automating SQL Server Database Creation for SharePoint
 
Introduction to F#
Introduction to F#Introduction to F#
Introduction to F#
 
Architecting Solutions for the Manycore Future
Architecting Solutions for the Manycore FutureArchitecting Solutions for the Manycore Future
Architecting Solutions for the Manycore Future
 

Automating PowerShell with SharePoint

  • 1. PowerShell SharePoint Talbott Crowell SPSBoston, September 25, 2010http://www.thirdm.com
  • 2. Unix-like shell Object oriented .NET Command line Scripting language What is PowerShell?
  • 3. Automated build and deploy Rapid prototyping Exploring “What If” scenarios Developer onboarding Administration automation Why PowerShell for SharePoint?
  • 4. When you want to make your team more agile Automation, automation, automation When developing, your daily build is like the projects heartbeat PowerShell can be the pacemaker Testing Use the PowerShell scripts to stand up an environment for running tests When use PowerShell?
  • 5. What do you know about a command line? DIR How about $a = DIR What is $a? .NET Object use gm or get-member to query properites Array $a[0] PowerShell Basics
  • 6. PowerShell Basics $a = DIR $a | gm Dates Demo - Basics
  • 7. Cmd, notepad PowerShell Command Windows PowerShell Integrated Scripting Environment (ISE) Import-Module ServerManager; Add-WindowsFeaturePowerShell-ISE PowerGUI Download from powergui.org Tools
  • 8. # for comment Verb-Noun convention for commandlets Write-Host “Hello World” Set-ExecutionPolicyUnrestricted .criptname to execute More Basics
  • 9. Comes with PowerShell Commandlets Get-SPSite New-SPSite New-SPWeb If you are running from standard PowerShell Add-PSSnapinmicrosoft.sharepoint.powershell-ErrorActionSilentlyContinue SharePoint 2010
  • 10. Get-SPSite Parameter: url New-SPSite Parameters: url, name, ownerAlias, template New-SPWeb Parameters: url, name, description, template… Other params: -AddToTopNav or -UseParentTopNav -AddToQuickLaunch Create Site Collections and Sites
  • 11. Your friend STSADM is still there You can call STSADM or any command line tool from PowerShell You can write your own command line tools with .NET Better yet, you can write your own PowerShell Commandlets! Inherit from Cmdletor PSCmdlet Gary Lapointe has WSS and MOSS Cmdlets! http://stsadm.blogspot.com/2009/02/downloads.html What about MOSS 2007 or WSS?
  • 12. When creating non-persistent tasks (i.e. get info) use: SPCmdlet When objects persist between commands, use: SPRemoveCmdletBase SPNewCmdletBase SPSetCmdletBase SPGetCmdletBase For more info, see Gary Lapointe’s blog post: http://stsadm.blogspot.com/2009/10/creating-custom-sharepoint-2010-cmdlets.html Creating 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 model Don’t forget to $SPSite.Dispose() Creating SharePoint Objects
  • 14. Series of scripts to build your site Cleanup script to destroy site Edit script, run cleanup, run script, view site Repeat Strategy
  • 15. Build2010.ps1 Calls other scripts Build2010_site_structure.ps1 Sets up the basic site structure and content types Build2010_upload_file.ps1 Uploads sample files to the site Build2010_set_logo.ps1 Adds site logo Build2010_add_users.ps1 Adds users to local machine and/or SharePoint groups Demo – series of scripts
  • 16. function Get-Theme([Microsoft.SharePoint.SPWeb]$SPWeb,[string]$themeName) Strong typed parameters Returns Microsoft.SharePoint.Utilities.ThmxTheme Defining functions
  • 17. Upload File Takes in 1 or more files Has 3 blocks Begin Process End Process is executed for each file gci 'C:ploadfilesamplesegal' | .uild2010_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 Cmdlet http://silverlight.sys-con.com/node/1370916 Other References
  • 19. Thank you. Questions?PowerShell SharePoint Talbott Crowell ThirdM.com http://talbottc.spaces.live.com Twitter: @talbott