module 3 administering and automating sharepoint

31
Module 3 Administering and Automating SharePoint

Upload: ruby-lee

Post on 31-Dec-2015

229 views

Category:

Documents


4 download

TRANSCRIPT

Page 1: Module 3 Administering and Automating SharePoint

Module 3

Administering and Automating SharePoint

Page 2: Module 3 Administering and Automating SharePoint

Module Overview

• Configuring Central Administration

• Administering SharePoint from the Command Line

• Automating SharePoint Operations with Windows PowerShell

Page 3: Module 3 Administering and Automating SharePoint

Lesson 1: Configuring Central Administration

• Administrative Options

• Central Administration

• Administrative Roles

Page 4: Module 3 Administering and Automating SharePoint

Administrative Options

• Central Administration

• Stsadm

C:\Program Files\Common Files\Microsoft Shared\web server extensions\14\BIN

• Windows PowerShell

• SharePoint 2010 Management Shell

Supports Stsadm

• Includes the BIN folder (STSADM) in its path configuration

Preloads the SharePoint snap-ins for Windows PowerShell

Page 5: Module 3 Administering and Automating SharePoint

Central Administration

• Web application

Everything is done using the app pool identityfor the Central Administration Web application: SP_Farm

If something is not working, be sure SP_Farm has permissions

• Local Administrators group on each SharePoint server

• SQL Server permissions

• Change the port

Windows PowerShell

Set-SPCentralAdministration -Port <PortNumber>

• Blocks port 443 (SSL)

• Blocks ports <1023 or >32767

Stsadm

stsadm –o setadminport <PortNumber>

Page 6: Module 3 Administering and Automating SharePoint

Administrative Roles

• Farm Administrators

Security Users Manage the Farm Administrators group

Capabilities

No default access to sites or content, but can take ownership

• Local Administrators

Members of Farm Administrators

Install products or applications, Web Parts, features

• Service application administrators

Click row of service application (don’t click the link!)

Ribbon Administrators

• Service application feature administrators

• Site collection administrators and site owners

Page 7: Module 3 Administering and Automating SharePoint

Lesson 2: Administering SharePoint from the Command Line

• SharePoint and Command-Line Administration

• Stsadm

• Introducing Windows PowerShell

• Demonstration: Windows PowerShell Basics

Page 8: Module 3 Administering and Automating SharePoint

SharePoint and Command-Line Administration

• SharePoint v1/v2 (2001–2003):

No command-line interface

• SharePoint 2007:

Stsadm: 182 Commands (MOSS)

• SharePoint 2010:

More than 600 Windows PowerShell cmdlets

Superset of Central Administration tasks

Windows PowerShell 2.0 is required

• Microsoft SharePoint ProductsPreparation Tool (PrerequisiteInstaller)

Stsadm: Supported but deprecated

Page 9: Module 3 Administering and Automating SharePoint

Stsadm

• Included but deprecated

However, a few functions can be performed only with Stsadm

• Buried in the Program Files folder

C:\Program Files\Common Files\Microsoft Shared\web server extensions\14\BIN

Add to %PATH% or use SharePoint 2010 Management Shell

• Command-line administration of SharePoint

Must be run directly on the SharePoint server

• Command syntax

stsadm –o <OperationName> [-parameter <Value> …]

• Get help

stsadm -help <OperationName>

Page 10: Module 3 Administering and Automating SharePoint

Introducing Windows PowerShell

• Command-line and task-based scripting language

• A framework

• Easy to learn, use, and adopt

• Why use Windows PowerShell?

The most powerful Windows-based command-line environment

• Windows PowerShell vs. Stsadm

Some overlap, but Windows PowerShell has unique capabilities including management of all new features

Install and configure SharePoint 2010

Manage service applications

Granular control of backup and restore

Page 11: Module 3 Administering and Automating SharePoint

Demonstration: Windows PowerShell Basics

In this demonstration, you will learn to use:

•Windows PowerShell

•SharePoint 2010 Management Shell

•cmdlets

•Tab completion

•Get-Help

•Objects

•Pipeline

•Aliases

•Variables

Page 12: Module 3 Administering and Automating SharePoint

Demonstration: Windows PowerShell Basics

• SharePoint 2010 Management Shell• cmdlet (Get-Command)

Not case sensitive Verb-Noun (Action-Object) format

• Tab completion• Get-Help• Objects• Pipeline ( | )• Aliases (Get-Alias)• Variables

$variable = value String can be with single or double quotation marks $_ is the current object in the pipeline

• Windows PowerShell on Microsoft TechNet

Page 13: Module 3 Administering and Automating SharePoint

Lesson 3: Automating SharePoint Operations with Windows PowerShell

• SharePoint 2010 Management Shell

• Delegate Permissions to Use Windows PowerShell

• Examine the SharePoint Logical Structure Using Windows PowerShell

• Create a SharePoint Intranet Using Windows PowerShell

• Objects, Members, Properties, and Methods

• Select, Sort, and Format Output

• Filtering Objects

• Typical Pipeline

• Variables

• Iteration (Looping)

• Iteration in Scripts

• Local, Global, and Remote Commands

• Windows PowerShell Scripts

Page 14: Module 3 Administering and Automating SharePoint

SharePoint 2010 Management Shell

• SharePoint 2010 Management Shell vs.Windows PowerShell

Windows PowerShell available on clients

SharePoint 2010 Management Shell only on SharePoint servers

• SharePoint 2010 Management Shell has

SharePoint snap-ins loaded automatically

• Part of the SharePoint.ps1 profile located in %CommonProgramFiles%\Microsoft Shared\Web Server Extensions\14\Config\PowerShell\Registration

• Windows PowerShell:

Add-PSSnapin Microsoft.SharePoint.PowerShell

ReuseThread option

Stsadm (/BIN folder) in path

Page 15: Module 3 Administering and Automating SharePoint

Delegate Permissions to Use Windows PowerShell• Requirements to use Windows PowerShell to administer

SharePoint WSS_ADMIN_WPG group on all servers in the farm

SharePoint_Shell_Access database role on database

Note: Setup user (SP_Admin) is not given rights by default

• Delegate these permissions with Add-SPShellAdmin

Add-SPShellAdmin -username <DOMAIN\user> -database (Get-SPContentDatabase <Content Database Name>)

To run Add-SPShellAdmin, you must be

•securityadmin server role on SQL instance

•db_owner role for the database

•Administrators membership on local computer

• You must also be a site collection owner

Set-SPSiteAdministration <SiteCollectionURL> -OwnerAlias <DOMAIN\user> -SecondaryOwnerAlias <DOMAIN\user>

• Management Shell Run as Administrator may be required

Page 16: Module 3 Administering and Automating SharePoint

Examine the SharePoint Logical Structure Using Windows PowerShell

• Examine the SharePoint Logical Structure with Get

Get-SPFarm, Get-SPWebApplication, Get-SPSite, Get-SPWeb

• Interface vs. Object Model Terminology

• Using the Pipeline

Page 17: Module 3 Administering and Automating SharePoint

Create a SharePoint Intranet Using Windows PowerShell

• Cmdlets

Remove-SPWebApplication

New-SPWebApplication

New-SPContentDatabase

New-SPSite

New-SPWeb

• Create the Intranet Web Application, Site Collection, and Site

• Create a Content Database, Site Collection, and Site

Page 18: Module 3 Administering and Automating SharePoint

Objects, Members, Properties, and Methods

• Cmdlets output objects

• Objects can be stored in variables for later use orpiped to a subsequent cmdlet for use as input by the cmdlet

• Objects have members: properties and methods

• A special kind of property is a collection

• Get-Member

object | Get-Member

object | Get-Member –MemberType Methods

object | Get-Member –MemberType Properties

Page 19: Module 3 Administering and Automating SharePoint

Select, Sort, and Format Output

• Write-Output Writes object to the console: The default “end of pipeline” command

Default properties are displayed

• Select-Object (alias: Select) Select * displays all properties

Select PropertyName [,PropertyName…] displays specific properties

Get-SPWebApplication "http://intranet.contoso.com" | Get-SPSite -limit all | Get-SPWeb -limit all | Select URL,WebTemplate

• Sort-Object (alias: Sort)

Get-SPWebApplication "http://intranet.contoso.com" | Get-SPSite -limit all | Get-SPWeb -limit all | Sort URL [-descending]

• Format-Table, Format-List (alias: fl)

• Export-CSV, ConvertTo-XML, Out-GridView

Page 20: Module 3 Administering and Automating SharePoint

Filtering Objects

• Where-Object (alias: Where, ?) Filters objects in the pipeline and passes only the filtered objects down

the pipeline to the next cmdlet

Get-SPWebApplication "http://intranet.contoso.com" | Get-SPSite -Limit ALL | Get-SPWeb -Limit ALL | Where-Object { $_.WebTemplate -eq "BLOG"}

Server-side filtering (-Filter parameter) for specific properties:

•SPWeb: Title and Template

•SPSite and SPSiteAdministration: Owner, SecondaryContact, LockState

•Use -Filter parameter (rather than Where-Object cmdlet) when possible

Get-SPWebApplication "http://intranet.contoso.com" | Get-SPSite -Limit All | Get-SPWeb -Limit All -Filter {$_.Template -eq "BLOG"}

• Operators

Page 21: Module 3 Administering and Automating SharePoint

Typical Pipeline

• Get objects | Filter objects (Where) | Manipulate | Select | Sort | Format/Export/Out/Convert/Save

Get-SPWebApplication "http://intranet.contoso.com" | Get-SPSite -Limit ALL | Get-SPWeb -Limit ALL | Where-Object { $_.WebTemplate -eq "BLOG"} | Select URL,Title,WebTemplate, LastItemModifiedDate, Created | Sort LastItemModifiedDate | Export-CSV desktop\StaleBlogs.csv

Page 22: Module 3 Administering and Automating SharePoint

Variables

• Variables start with $

Assign a variable

$username = “CONTOSO\SP_Admin"

$password = Read-Host "Enter the password: " -AsSecureString

Use a variable

Write-Host "The user name is: " $username

Write-Host "The password is: " $password

•Note: This doesn’t work! Secure, one-way passwords only!

• Windows PowerShell has built-in variables that you can call at run time

$true, $false

$home

Many more: Get-Help about_automatic_variables

Page 23: Module 3 Administering and Automating SharePoint

Iteration (Looping)

ForEach-Object (%, ForEach)

•Iterates through each object in the pipeline

•Sometimes, this is done implicitly by a cmdlet on the receiving side of the pipeline

•For-Each is helpful where a cmdlet does not do its own iteration

Get-SPWebApplication "http://intranet.contoso.com" | Get-SPSite "http://intranet.contoso.com/sites/Sales" | ForEach-Object { Enable-SPFeature "Ratings" -url $_.url -whatif }

•Commonly used alias: %

Page 24: Module 3 Administering and Automating SharePoint

Iteration in Scripts• Syntax

ForEach-Object ($variable in $array){ Actions}

$i = ("HR", "Marketing") Creating an ArrayParentheses are optional here

ForEach($url in $i) Iterate through each item in the arrayAssign $url to the current item

{ Start loop actions

New-SPContentDatabase -Name WSS_Content_Intranet_$url -WebApplication http://intranet.contoso.com

 New-SPSite -Url http://intranet.contoso.com/sites/$url -ContentDatabase WSS_Content_Intranet_$url -OwnerAlias CONTOSO\SP_Admin -Template "STS#0"

} End loop actions

Blank line starts execution

Page 25: Module 3 Administering and Automating SharePoint

Local, Global, and Remote Commands

• Two types of commands:

Local (“box”)—must be run on each box

• Examples: Start-SPServiceInstance, Connect-SPConfigurationDatabase

Global (“config db”) —run only once per farm

• Examples: Set-SPWebApplication, New-SPSite

• Remoting

Windows PowerShell 2.0 features Windows PowerShell Remoting

From your machine, perform Windows PowerShell commands and scripts on a remote machine

Think “psexec.exe”

Page 26: Module 3 Administering and Automating SharePoint

Windows PowerShell Scripts

• Creating scripts (.ps1) Windows PowerShell Integrated Scripting Environment (ISE)

Readability

• Can be multiline or one line: Multiline

- Join commands on a single line with ;

• Can be full cmdlets or aliases: Full cmdlets

- ForEach-Object alias is %

• Execution Set-ExecutionPolicy -unrestricted

Read up on script signing

• Schedule a Windows PowerShell script with Task Scheduler Command: PowerShell.exe

Arguments: path\scriptname.ps1

• Scripts you’ll see in this course

Page 27: Module 3 Administering and Automating SharePoint

Lab A: Automating SharePoint with Windows PowerShell

• Exercise 1: Adding SharePoint Functionality to Windows PowerShell

• Exercise 2: Delegating the Ability to Use Windows PowerShell to Manage SharePoint

• Exercise 3: Reporting Web and Site Collection Properties

• Exercise 4: Creating Site Collections Using Windows PowerShell

• Exercise 5: Creating and Updating Items

Logon information

Estimated time: 30 minutes

Page 28: Module 3 Administering and Automating SharePoint

Scenario

• You are responsible for ensuring that the SharePoint farm can be built consistently in both lab and production environments, and that the farm can be rebuilt in the event of a catastrophic failure. Additionally, you are required to produce weekly reports showing the webs and storage utilization of each site collection in the production farm. To meet these goals, you must build Windows PowerShell scripts that can automate SharePoint management tasks.

Page 29: Module 3 Administering and Automating SharePoint

Lab B: Administering SharePoint with Stsadm

• Exercise 1: Executing Stsadm Commands

Logon information

Estimated time: 20 minutes

Page 30: Module 3 Administering and Automating SharePoint

Scenario

• Contoso’s policies encourage and in some cases mandate the automation of common tasks. As such, your Microsoft Office SharePoint Server 2007 environment had several Stsadm scripts that were used to create site collections and webs.

Page 31: Module 3 Administering and Automating SharePoint

Module Review and Takeaways

• Review Questions