PowerShell for SharePoint Admins

Post on 18-Nov-2014

2,087 views 2 download

Tags:

description

 

transcript

Rick Taylor

PowerShell for SharePoint Admins

Thank you to Sponsors!

• Who am I???• Who am I ??????????The Guardian of Lost Souls

The Powerful

The PleasurableThe Indestructible

Rick Taylor

Slick Rick – if you’re nasty

• Rick Taylor, MCSE, MCT

– Richard.Taylor@perficient.com– 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• Why should you know PowerShell• Windows PowerShell basics • Windows PowerShell scripts for

administrators

• 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?

• 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?

• 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?

• cmdlet – pronounced "command-let“– More than 500 cmdlets for SharePoint alone

Windows PowerShell Basics

Windows PowerShell Basics• cmdlets = verbs (actions) & nouns (objects)

– Combine the two to build specific commands– Examples

• Get-SPSite• Get = Verb • SPSite = Noun

Windows PowerShell BasicsVerb Operation

Get- Enumerate

New-(static cmdlet)

Create

Set-

Modify

Remove- Delete

• 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

• 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

Differences in Get-help: -full

Differences in Get-help: -detailed

Differences in Get-help: -examples

CHECKING OUT WINDOWS POWERSHELL

DEMO

• Build scripts to easily execute through common commands and tasks

• Develop using PowerShell ISE or other shells• Schedule using Task Scheduler.

PowerShell Scripts

• Examples:– Activate a feature across multiple site collections– Provisioning of Managed Accounts– Creating of New Sites– Backup all Site Collections in Farm

PowerShell Scripts

• 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

Slick Rick’s Picks

SharePoint Community in Philadelphia

• Tri-State SharePoint Users Group– SharePoint (2010 & 2007)

• Administrators• Developers• IT Pros

– Keynote and related Hands-on Lab each meeting– “On SharePoint Development”

• Our lecture series on general SharePoint Development topics and how to improve those skills

– Meetings: 2nd Tuesday of the month, 5:30pm – 9:00pm, Microsoft Malvern MTC

• Website: www.TriStateSharePoint.org• Email: info@tristatesharepoint.org• Twitter: @tristateSP