Your SlideShare is downloading. ×
0
Automating PowerShell with SharePoint
Automating PowerShell with SharePoint
Automating PowerShell with SharePoint
Automating PowerShell with SharePoint
Automating PowerShell with SharePoint
Automating PowerShell with SharePoint
Automating PowerShell with SharePoint
Automating PowerShell with SharePoint
Automating PowerShell with SharePoint
Automating PowerShell with SharePoint
Automating PowerShell with SharePoint
Automating PowerShell with SharePoint
Automating PowerShell with SharePoint
Automating PowerShell with SharePoint
Automating PowerShell with SharePoint
Automating PowerShell with SharePoint
Automating PowerShell with SharePoint
Automating PowerShell with SharePoint
Automating PowerShell with SharePoint
Upcoming SlideShare
Loading in...5
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

×
Saving this for later? Get the SlideShare app to save on your phone or tablet. Read anywhere, anytime – even offline.
Text the download link to your phone
Standard text messaging rates apply

Automating PowerShell with SharePoint

2,200

Published on

0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total Views
2,200
On Slideshare
0
From Embeds
0
Number of Embeds
1
Actions
Shares
0
Downloads
46
Comments
0
Likes
0
Embeds 0
No embeds

Report content
Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
No notes for slide

Transcript

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

×