1 / 18

Automating SharePoint Tasks with PowerShell

Automating SharePoint Tasks with PowerShell. Rick Toner MCSD, MCPD, MCITP Rick@GetSharePoint.Com Blog: http://www.getsharepoint.com/blog. Prior Version of SharePoint. Stsadm and PsConfig Command line driven text results only. SharePoint 2010+. Welcome to Automation!

byrd
Download Presentation

Automating SharePoint Tasks with PowerShell

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Automating SharePoint Tasks with PowerShell Rick Toner MCSD, MCPD, MCITP Rick@GetSharePoint.Com Blog: http://www.getsharepoint.com/blog

  2. Prior Version of SharePoint • Stsadm and PsConfig • Command line driven text results only

  3. SharePoint 2010+ • Welcome to Automation! • PowerShell + SharePoint = time savings and validation!

  4. What is Windows PowerShell? • Dynamic scripting language • Next generation commandline/scripting environment from Microsoft. • General purpose programming language

  5. What can it do? • Automate complex, repetitive tasks • Build command line utilities • .NET Interactive Prompt • Windows Server management • SharePoint 2010+ • IIS 7.0+

  6. Getting Started • How do I get it? • If you're using Windows 7 or Windows Server 2008 R2, you have nothing to do - it's already there. • All other versions can download it at • http://support.microsoft.com/kb/968929

  7. Some gotchas! • Adjust PowerShell to allow script execution. • PS> Set-ExecutionPolicy Unrestricted • What if it just won't run? • http://technet.microsoft.com/en-us/library/ee176949.aspx

  8. Cmdlets • Standardized naming scheme for cmdlets • <Verb>-<Noun> where the verb specifies the action and the noun specifies the object to operate on. • Examples • Get-Help, Remove-Item

  9. Scripting Language: Variables • Variables are always prefixed with $ except: • gps -OutVariableProcs –ErrorVariable Err • Set-Variable FirstName 'John' • Can be loosely or strongly typed: • $a = 5 • $a = "hi" • [int]$b = 5 • $b = "hi" # Errors since $b is type int • $c = [int]"7" # Coerce string to int • Automatic variables • $null, $true, $false, $error, $?, $LastExitCode, $OFS, $MyInvocation

  10. Scripting Language: Variables “c” indicates case sensitive Remember: Many operators start with hyphens

  11. A better way to script! • PowerGUI Script Editor • Debugging • Variable watch (local window) • Superior scripting UI • Intellisense (Auto complete) • Snippets • Commenting out blocks

  12. Other demo scripts and tools!

  13. Any good resources? • First and foremost in PowerShell; of course! • PS> Get-Help (Any command) • PS> Get-Help about_Windows_PowerShell_2.0

  14. Resources continued

  15. Resources continued

  16. SharePoint PowerShell Books • A++ Book! • Automating SharePoint 2010 with Windows PowerShell 2.0 • http://www.wiley.com/WileyCDA/WileyTitle/productCd-0470939206.html

  17. Books continued • PowerShell for Microsoft SharePoint 2010 Administrators • http://www.mhprofessional.com/product.php?isbn=0071747974 • PowerShell for SharePoint 2010 How-To • http://www.informit.com/store/product.aspx?isbn=067233559X

  18. Questions? • Rick’s blog - http://www.getsharepoint.com/blogemail: Rick@GetSharePoint.com Twitter ID: rtonerii • Western Carolina SharePoint Users Group • Arden, March 8th, 2012http://www.GetSharePoint.com

More Related