• Save
Making Life Easier with PowerShell (SPSVB 2012)
Upcoming SlideShare
Loading in...5
×
 

Making Life Easier with PowerShell (SPSVB 2012)

on

  • 2,838 views

Have you ever spent an afternoon setting site collection properties manually on every site collection in your farm? How about going through and activating features following an upgrade? These are just ...

Have you ever spent an afternoon setting site collection properties manually on every site collection in your farm? How about going through and activating features following an upgrade? These are just two simple examples of where PowerShell can turn an entire afternoon worth of work into just a few minutes. In this session we’ll start off with a familiarization of PowerShell and progress into capabilities and usage scenarios of the out of the box SharePoint 2010 cmdlets.

Presented at SharePoint Saturday, Virginia Beach (January 7, 2012)

Statistics

Views

Total Views
2,838
Views on SlideShare
1,716
Embed Views
1,122

Actions

Likes
1
Downloads
0
Comments
0

3 Embeds 1,122

http://mike-greene.com 1106
http://162.243.170.104 14
http://www.mike-greene.com 2

Accessibility

Categories

Upload Details

Uploaded via as Microsoft PowerPoint

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment
  • Test-Path $profileIf result is FALSENew-Item –type file –force $profileNotepad $profile
  • Get-Command -PSSnapin “Microsoft.SharePoint.Powershell”
  • Idera, $199 per user

Making Life Easier with PowerShell (SPSVB 2012) Making Life Easier with PowerShell (SPSVB 2012) Presentation Transcript

  • MAKING LIFE EASIERWITH POWERSHELL January 7, 2012
  • AGENDA • What is PowerShell • Working with PowerShell • When to Use PowerShell • Top 10 SharePoint 2010 Cmdlets • Using the PowerShell Pipeline • User Scenarios • Tools & Resources1/7/2012 Making Life Easier with PowerShell 3
  • Core Concepts WHAT IS POWERSHELL1/7/2012 Making Life Easier with PowerShell 4
  • WHAT IS POWERSHELL • Microsoft task automation framework built on the .NET framework • Command-line shell • Scripting language (*.ps1) • Common “shell” to Microsoft technologies (AD, SQL, SP, Server, etc.) • Full access to COM (Component Object Model) and WMI (Windows Management Instrumentation) for local and remote system management • Replacement to STSADM (deprecated) • PowerShell > STSADM • All STSADM operations have a PowerShell equivalent • Integrated support for multiple platforms/services (not SP specific) • Easily Extendable1/7/2012 Making Life Easier with PowerShell 5
  • Core Concepts WORKING WITH POWERSHELL1/7/2012 Making Life Easier with PowerShell 6
  • POWERSHELL SNAP-INS • PowerShell snap-in registers sets of cmdlets and/or providers, extending the default functionality of the shell • Similar to a web browser plug-in • Added and removed as needed during user session1/7/2012 Making Life Easier with PowerShell 7
  • POWERSHELL CMDLETS • A cmdlet (“command-let”) is a specific command executed in the PowerShell environment • Following a common {verb}-{noun} naming convention, cmdlet functions are typically easily understood, ie: Add-PSSnapin, Get- SPWeb, etc. • Used like a function, cmdlets take one or more input parameters/objects, and output objects or arrays of objects • Cmdlets can be piped together, allowing the output object of one to become the input object of another • Objects are always processed individually, if multiple input objects are specified, each object will be fully processed before the next is begun1/7/2012 Making Life Easier with PowerShell 8
  • WHEN TO USE POWERSHELL • Making life “easier” with PowerShell should equate to increased efficiency, lower cost, and lower turnaround • Identify those processes which are repetitive in nature or those that require extended “hands-on” time1/7/2012 Making Life Easier with PowerShell 9
  • GETTING STARTED SharePoint 2010 Management Shell PowerShell with the SharePoint Snap-in Loaded1/7/2012 Making Life Easier with PowerShell 10
  • STARTING POWERSHELL PowerShell 2.01/7/2012 Making Life Easier with PowerShell 11
  • Demonstration CREATE A POWERSHELL PROFILE1/7/2012 Making Life Easier with PowerShell 12
  • SharePoint 2010 TOP 10 POWERSHELL CMDLETS1/7/2012 Making Life Easier with PowerShell 13
  • GET-HELP • Overview • Displays help about Windows PowerShell cmdlets and concepts • Examples • Get-Help {cmdlet} • Get-Help Test-Path • Get-Help Test-Path -Detailed • Get-Help Test-Path –Examples • Get-Help {topic} • Get-Help Snapin1/7/2012 Making Life Easier with PowerShell 14
  • GET-MEMBER • Overview • Gets the properties and methods of objects. Specify an object using the InputObject parameter, or pipe an object to Get-Member. • Examples • Get-Member –InputObject $object • $object | Get-Member1/7/2012 Making Life Easier with PowerShell 15
  • GET-SPFARM • Overview • Returns the local SharePoint farm. • Examples • Get-SPFarm • $farm = Get-SPFarm $farm.Properties1/7/2012 Making Life Easier with PowerShell 16
  • GET-SPWEBAPPLICATION • Overview • Returns all web applications that match the given criteria. If no identity is specified, all web applications are returned. The Central Administration web application is ignored unless specified directly or the IncludeCentralAdministration flag is specified. • Examples • Get-SPWebApplication • Get-SPWebApplication –IncludeCentralAdministration • Get-SPWebApplication http://intranet1/7/2012 Making Life Easier with PowerShell 17
  • GET-SPSITE • Overview • Returns all the site collections that match the given criteria. If no identity is specified, the farm is scope is used. • Examples • Get-SPSite • Get-SPSite http://intranet • Get-SPSite http://intranet/depts/facilities1/7/2012 Making Life Easier with PowerShell 18
  • GET-SPWEB • Overview • Returns all subsites that match the given criteria. • Examples • Get-SPWeb http://intranet/depts/HR/benefits • Get-SPWeb http://intranet/depts/HR/* • Get-SPWeb http://intranet/* –filter {$_.Template –eq “STS#0”}1/7/2012 Making Life Easier with PowerShell 19
  • GET-SPSERVICEAPPLICATION • Overview • Returns the specified service application. If no service application is specified, all are returned. • Examples • Get-SPServiceApplication • Get-SPServiceApplication | select Name, Status1/7/2012 Making Life Easier with PowerShell 20
  • GET-SPCONTENTDATABASE • Overview • Returns one or more content databases. • Examples • Get-SPContentDatabase • Get-SPContentDatabase –WebApplication http://intranet • Get-SPContentDatabase –Site http://intranet1/7/2012 Making Life Easier with PowerShell 21
  • TEST-SPCONTENTDATABASE • Overview • Tests a content database against a web application to verify all customizations referenced within the content database are also installed in the web application. Content databases do not need to be mounted for validation to complete. • Examples • Test-SPContentDatabase –name Lab_Content_Intranet –WebApplication http://intranet1/7/2012 Making Life Easier with PowerShell 22
  • EXPORT-CLIXML & EXPORT-CSV • Overview • Overview • Creates an XML-based • Converts objects into a representation of an series of comma- object or objects & stores separated value strings & in a file. saves file. • Examples • Examples • $sites = Get-SPSite • $sites = Get-SPSite Export-Clixml -InputObject Export-CSV -InputObject $sites -Path $sites -Path c:sites.xml c:sites.csv • Get-SPSite | Export-Clixml • Get-SPSite | Export-CSV c:sites.xml c:sites.csvs1/7/2012 Making Life Easier with PowerShell 23
  • Demonstration LIST ALL SHAREPOINT CMDLETS1/7/2012 Making Life Easier with PowerShell 24
  • POWERSHELL PIPELINE • The use of the PowerShell Pipeline allows the output object of one cmdlet to become the input object of another • “Piping” is performed by using the pipe character “ | ” between cmdlets • Applies to native cmdlets (such as sorting, logical operations, and data manipulation) and functional cmdlets (such as those for SharePoint) • Logical Example: Get-SPContentDatabase -WebApplication http://intranet | Where {$_.CurrentSiteCount -gt 5} • Functional Example: Get-SPSite http://intranet | Get-SPWeb | Enable-SPFeature -Identity “MyFeature”1/7/2012 Making Life Easier with PowerShell 25
  • Demonstration USER SCENARIOS1/7/2012 Making Life Easier with PowerShell 26
  • TOOLS & RESOURCES • Tools • Windows PowerShell Integrated Scripting Environment (ISE) • Idera PowerShell Plus (free trial available) • Resources • STSADM -> PowerShell Mapping http://technet.microsoft.com/en-us/library/ff621081.aspx • Scripting with Windows PowerShell (5 part webcast series) http://technet.microsoft.com/en-us/scriptcenter/dd742419 • PowerShell Power Hour (monthly lunchtime webcasts) http://idera.com/Education/PowerShell-Webcasts/ • SP2010 Visual PowerShell Command Builder http://www.microsoft.com/resources/TechNet/en- us/Office/media/WindowsPowerShell/WindowsPowerShellCommandBuilder.ht ml • Automating Microsoft SharePoint 2010 Administration with Windows PowerShell 2.0. Gary Lapointe, Shannon Bray • Automating Microsoft Windows Server 2008 R2 Administration with Windows PowerShell 2.0. Matthew Hester, Sarah Dutkiewicz1/7/2012 Making Life Easier with PowerShell 27
  • QUESTIONS?
  • MICHAEL GREENE@webdes03 mike-greene.com