MAKING LIFE EASIERWITH POWERSHELL    November 5, 2011
Special Thanks to Our Sponsors
SharePintEveryone is invited to SharePintImmediately following SharePoint Saturday Richmond(or around 6:20 PM)Meet at alof...
AGENDA        •   What is PowerShell        •   Working with PowerShell        •   When to Use PowerShell        •   Top 1...
Core Concepts        WHAT IS POWERSHELL11/7/2011               Making Life Easier with PowerShell   5
WHAT IS POWERSHELL        •   Microsoft task automation framework built on the .NET framework             • Command-line s...
Core Concepts        WORKING WITH POWERSHELL11/7/2011               Making Life Easier with PowerShell   7
POWERSHELL SNAP-INS        •   PowerShell snap-in registers sets of cmdlets and/or providers,            extending the def...
POWERSHELL CMDLETS        •   A cmdlet (“command-let”) is a specific command executed in the            PowerShell environ...
WHEN TO USE POWERSHELL        •   Making life “easier” with PowerShell should equate to increased            efficiency, l...
GETTING STARTED        SharePoint 2010        Management Shell        PowerShell with the        SharePoint Snap-in Loaded...
STARTING POWERSHELL        PowerShell 2.011/7/2011                Making Life Easier with PowerShell   12
Demonstration        CREATE A POWERSHELL PROFILE11/7/2011               Making Life Easier with PowerShell   13
SharePoint 2010        TOP 10 POWERSHELL CMDLETS11/7/2011             Making Life Easier with PowerShell   14
GET-HELP        •   Overview            • Displays help about Windows PowerShell cmdlets and concepts        •   Examples ...
GET-MEMBER        •   Overview            • Gets the properties and methods of objects. Specify an object              usi...
GET-SPFARM        •   Overview            • Returns the local SharePoint farm.        •   Examples            • Get-SPFarm...
GET-SPWEBAPPLICATION        •   Overview            • Returns all web applications that match the given criteria. If no   ...
GET-SPSITE        •   Overview            • Returns all the site collections that match the given criteria. If no         ...
GET-SPWEB        •   Overview            • Returns all subsites that match the given criteria.        •   Examples        ...
GET-SPSERVICEAPPLICATION        •   Overview            • Returns the specified service application. If no service applica...
GET-SPCONTENTDATABASE        •   Overview            • Returns one or more content databases.        •   Examples         ...
TEST-SPCONTENTDATABASE        •   Overview            • Tests a content database against a web application to verify all  ...
EXPORT-CLIXML & EXPORT-CSV        •   Overview                                        •   Overview            • Creates an...
Demonstration        LIST ALL SHAREPOINT CMDLETS11/7/2011               Making Life Easier with PowerShell   25
POWERSHELL PIPELINE        •   The use of the PowerShell Pipeline allows the output object of one cmdlet            to bec...
Demonstration        USER SCENARIOS11/7/2011               Making Life Easier with PowerShell   27
TOOLS & RESOURCES        •   Tools            • Windows PowerShell Integrated Scripting Environment (ISE)            • Ide...
QUESTIONS?
MICHAEL GREENE@webdes03   mike-greene.com
Upcoming SlideShare
Loading in...5
×

Making Life Easier with PowerShell - SPSRIC

1,947

Published on

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, Richmond (November 5, 2011)

Published in: Technology
0 Comments
2 Likes
Statistics
Notes
  • Be the first to comment

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

No notes for slide
  • 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 - SPSRIC

    1. 1. MAKING LIFE EASIERWITH POWERSHELL November 5, 2011
    2. 2. Special Thanks to Our Sponsors
    3. 3. SharePintEveryone is invited to SharePintImmediately following SharePoint Saturday Richmond(or around 6:20 PM)Meet at aloft Richmond West3939 Duckling DriveGlen Allen, VA 23060(down the street from Dave & Buster’s)Then we will hop to the next locationand the next within walking distance!SharePint: a gathering of SharePoint enthusiasts for fun, food, and drink.
    4. 4. AGENDA • What is PowerShell • Working with PowerShell • When to Use PowerShell • Top 10 SharePoint 2010 Cmdlets • Using the PowerShell Pipeline • User Scenarios • Tools & Resources11/7/2011 Making Life Easier with PowerShell 4
    5. 5. Core Concepts WHAT IS POWERSHELL11/7/2011 Making Life Easier with PowerShell 5
    6. 6. 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 Extendable11/7/2011 Making Life Easier with PowerShell 6
    7. 7. Core Concepts WORKING WITH POWERSHELL11/7/2011 Making Life Easier with PowerShell 7
    8. 8. 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 session11/7/2011 Making Life Easier with PowerShell 8
    9. 9. 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 begun11/7/2011 Making Life Easier with PowerShell 9
    10. 10. 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” time11/7/2011 Making Life Easier with PowerShell 10
    11. 11. GETTING STARTED SharePoint 2010 Management Shell PowerShell with the SharePoint Snap-in Loaded11/7/2011 Making Life Easier with PowerShell 11
    12. 12. STARTING POWERSHELL PowerShell 2.011/7/2011 Making Life Easier with PowerShell 12
    13. 13. Demonstration CREATE A POWERSHELL PROFILE11/7/2011 Making Life Easier with PowerShell 13
    14. 14. SharePoint 2010 TOP 10 POWERSHELL CMDLETS11/7/2011 Making Life Easier with PowerShell 14
    15. 15. 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 Snapin11/7/2011 Making Life Easier with PowerShell 15
    16. 16. 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-Member11/7/2011 Making Life Easier with PowerShell 16
    17. 17. GET-SPFARM • Overview • Returns the local SharePoint farm. • Examples • Get-SPFarm • $farm = Get-SPFarm $farm.Properties11/7/2011 Making Life Easier with PowerShell 17
    18. 18. 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://intranet11/7/2011 Making Life Easier with PowerShell 18
    19. 19. 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/facilities11/7/2011 Making Life Easier with PowerShell 19
    20. 20. 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”}11/7/2011 Making Life Easier with PowerShell 20
    21. 21. GET-SPSERVICEAPPLICATION • Overview • Returns the specified service application. If no service application is specified, all are returned. • Examples • Get-SPServiceApplication • Get-SPServiceApplication | select Name, Status11/7/2011 Making Life Easier with PowerShell 21
    22. 22. GET-SPCONTENTDATABASE • Overview • Returns one or more content databases. • Examples • Get-SPContentDatabase • Get-SPContentDatabase –WebApplication http://intranet • Get-SPContentDatabase –Site http://intranet11/7/2011 Making Life Easier with PowerShell 22
    23. 23. 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://intranet11/7/2011 Making Life Easier with PowerShell 23
    24. 24. 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.csvs11/7/2011 Making Life Easier with PowerShell 24
    25. 25. Demonstration LIST ALL SHAREPOINT CMDLETS11/7/2011 Making Life Easier with PowerShell 25
    26. 26. 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”11/7/2011 Making Life Easier with PowerShell 26
    27. 27. Demonstration USER SCENARIOS11/7/2011 Making Life Easier with PowerShell 27
    28. 28. 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/ • 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 Dutkiewicz11/7/2011 Making Life Easier with PowerShell 28
    29. 29. QUESTIONS?
    30. 30. MICHAEL GREENE@webdes03 mike-greene.com

    ×