Rick Taylor
PowerShell for SharePoint Admins
3 | SharePoint Saturday New York City 2011
Housekeeping Please remember to visit the ATE & Open
Spaces for a chance to win an XBOX/Kinect. You can also enter into a raffle for an SPC Pass if you visit the sponsor booths to get your bingo card signed. All other prizes are related to ending session evaluations.
Follow SharePoint Saturday New York City on Twitter @spsnyc and hashtag #spsnyc
4 | SharePoint Saturday New York City 2011
Rick Taylor, MCSE, MCT
[email protected] SharePoint architect, formerly with Microsoft
SharePoint Platform Architecture Team for SharePoint Online
Contact http://blogs.technet.com/ritaylor Twitter: @SLKRCK
Agenda
What is Windows PowerShell Windows PowerShell basics Windows PowerShell scripts for
administrators
6 | SharePoint Saturday New York City 2011
Command-line interface and scripting language used for SharePoint Server administration Complements CMD Extends STSADM Uses XML & Objects Built on the .Net Framework
What is Windows PowerShell?
7 | SharePoint Saturday New York City 2011
Complete command-line system that is far more powerful than any previous Windows-based command-line prompt environment.
Provides: More Control More Efficiency More Productivity
Why do we care?
8 | SharePoint Saturday New York City 2011
STSADM still available to support backwards compatibility Can leverage it in Windows PowerShell scripts
There are still some things that STSADM can do, that Windows PowerShell cannot, so you still need it! Ability to run against SQL Snapshots, instead of production. More granular control for backup / restore.
What about STSADM?
9 | SharePoint Saturday New York City 2011
cmdlet pronounced "command-let“ More than 500 cmdlets for SharePoint alone
Windows PowerShell Basics
10 | SharePoint Saturday New York City 2011
Windows PowerShell Basics cmdlets = verbs (actions) & nouns (objects) Combine the two to build specific commands Examples
Get-SPSite Get = Verb SPSite = Noun
11 | SharePoint Saturday New York City 2011
Get a list of all commands: Get-Command –noun sp*
Get help for a specific command: Get-Help <cmdlet>
Getting the list of SharePoint cmdlets
12 | SharePoint Saturday New York City 2011
For more detailed help add the following parameters:
Get-Help <cmdlet> -full
Get-Help <cmdlet> -examples
Get-Help <cmdlet> -detailed
Getting the list of SharePoint cmdlets
13 | SharePoint Saturday New York City 2011
Differences in Get-help: -full
14 | SharePoint Saturday New York City 2011
Differences in Get-help: -detailed
15 | SharePoint Saturday New York City 2011
Differences in Get-help: -examples
CHECKING OUT WINDOWS POWERSHELLDEMO
17 | SharePoint Saturday New York City 2011
Build scripts to easily execute through common commands and tasks
Develop using PowerShell ISE or other shells Schedule using Task Scheduler.
PowerShell Scripts
18 | SharePoint Saturday New York City 2011
Examples: Activate a feature across multiple site collections Provisioning of Managed Accounts Creating of New Sites Backup all Site Collections in Farm
PowerShell Scripts
19 | SharePoint Saturday New York City 2011
Sample Script:$LsaPath = "HKLM:\System\CurrentControlSet\Control\Lsa"$LsaPathValue = Get-ItemProperty -path $LsaPathIf (-not ($LsaPathValue.DisableLoopbackCheck -eq "1")){
New-ItemProperty HKLM:\System\CurrentControlSet\Control\Lsa -Name "DisableLoopbackCheck" -value "1" -PropertyType dword -Force | Out-Null}
Scripting Syntax
Syntax Description
$ Denotes a variable.
Denotes typing on the same line.
| Sends the output of the preceding cmdlet to the next cmdlet.
If ( ) Evaluate condition in ( ) and execute if true.
WINDOWS POWERSHELL SCRIPTS IN SHAREPOINT
DEMO
21 | SharePoint Saturday New York City 2011
Slick Rick’s Picks
22 | SharePoint Saturday New York City 2011
Windows PowerShell for SharePoint Foundation 2010 http://technet.microsoft.com/en-us/library/ee662510(office.14
).aspx Windows PowerShell Getting Started Guide
http://msdn.microsoft.com/en-us/library/aa973757(VS.85).aspx
Windows PowerShell Cheat Sheet http://refcardz.dzone.com/refcardz/windows-powershell
STSADM to Windows PowerShell mapping http://technet.microsoft.com/en-us/library/ff621084.aspx
Zach Rosenfield’s blog http://
sharepoint.microsoft.com/blogs/zach/default.aspx
Additional PowerShell Resources
Slide Title Here
Verdana 16 or 14 pt bold
Verdana 14 or 12 pt
Stock photography images are available for use here:
https://wiki.perficient.com/confluence/display/mktg/Stock+Images
Section Break/Divider Slide
26 | SharePoint Saturday New York City 2011
Outline & Agenda
Thanks to Our Sponsors!Enterprise
Standard
Foundation
Office 365
Prize