Download presentation
Presentation is loading. Please wait.
1
Module 3 Administering and Automating SharePoint
2
Module Overview Configuring Central Administration Administering SharePoint from the Command Line Automating SharePoint Operations with Windows PowerShell
3
Lesson 1: Configuring Central Administration Administrative Options Central Administration Administrative Roles
4
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
5
Central Administration Web application Everything is done using the app pool identity for 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 Blocks port 443 (SSL) Blocks ports 32767 Stsadm stsadm –o setadminport
6
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
7
Lesson 2: Administering SharePoint from the Command Line SharePoint and Command-Line Administration Stsadm Introducing Windows PowerShell Demonstration: Windows PowerShell Basics
8
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 Products Preparation Tool (PrerequisiteInstaller) Stsadm: Supported but deprecated
9
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 [-parameter …] Get help stsadm -help
10
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
11
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
12
Notes Page Over-flow Slide. Do Not Print Slide. See Notes pane.
16
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
17
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
18
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
19
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 -database (Get-SPContentDatabase ) 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 -OwnerAlias -SecondaryOwnerAlias Management Shell Run as Administrator may be required
20
Notes Page Over-flow Slide. Do Not Print Slide. See Notes pane.
22
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
23
Examine the SharePoint Structure with Get Get-SPFarm Get-SPWebApplication Leaves out Central Administration by default -IncludeCentralAdminsitration Get-SPSite Default limit of 20 -limit all Always leaves out Central Administration Get-SPWeb Default limit of 200 -limit all
24
Notes Page Over-flow Slide. Do Not Print Slide. See Notes pane.
25
Interface vs. Object Model Terminology Tip: Banish the word site from your discussion UI & DocumentationObject Model FarmSPFarm Web applicationSPWebApplication Site collectionSPSite Site, Web site, Web, subweb, subsite SPWeb What Users Say Site
26
Using the Pipeline Pipeline — perform commands on one or more objects Get-SPSite http://intranet.contoso.com | Get-SPWeb –limit all Get-SPWebApplication http://intranet.contoso.com | Get-SPSite -limit all | Get-SPWeb -limit all ? How about with Central Administration ?
27
Notes Page Over-flow Slide. Do Not Print Slide. See Notes pane.
28
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 the Intranet Web Application, Site Collection, and Site Create a Content Database, Site Collection, and Site
29
Create the Intranet Web Application, Site Collection, and Site Remove-SPWebApplication Remove-SPWebApplication http://intranet.contoso.com -DeleteIISSite -RemoveContentDatabase -Confirm:$false New-SPWebApplication New-SPWebApplication -Name "Contoso Intranet" -Port 80 -HostHeader "intranet.contoso.com" -URL "http://intranet.contoso.com:80" -ApplicationPool "SharePoint Web Applications" -ApplicationPoolAccount (Get-SPManagedAccount "CONTOSO\SP_Service") -DatabaseName "WSS_Content_Intranet" New-SPSite New-SPSite -Url "http://intranet.contoso.com" -ContentDatabase WSS_Content_Intranet -Name "Contoso Intranet" -OwnerAlias "CONTOSO\SP_Admin" - Template "BLANKINTERNET#1"
30
Notes Page Over-flow Slide. Do Not Print Slide. See Notes pane.
31
Create a Content Database, Site Collection, and Site New-SPContentDatabase New-SPContentDatabase -Name WSS_Content_Intranet_Sales -WebApplication http://intranet.contoso.com New-SPSite New-SPSite -Url "http://intranet.contoso.com/sites/Sales" -ContentDatabase WSS_Content_Intranet_Sales -Name "Sales" -OwnerAlias “CONTOSO\SP_Admin“ -Template "STS#0" New-SPWeb Get-SPWebTemplate New-SPWeb "http://intranet.contoso.com/sites/Sales/Blogs" -Name "Sales Execs" -Template “BLOG#0"
32
Objects, Members, Properties, and Methods Cmdlets output objects Objects can be stored in variables for later use or piped 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
33
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
34
Notes Page Over-flow Slide. Do Not Print Slide. See Notes pane.
35
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
36
Comparison operators -eq -- Equal to -ne -- Not equal to -lt -- Less than -le -- Less than or equal to -gt -- Greater than -ge -- Greater than or equal to -like - Like; uses wildcards for pattern matching Logical operators -and -or
37
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
38
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
39
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: %
40
Iteration in Scripts Syntax ForEach-Object ($variable in $array) { Actions } $i = ("HR", "Marketing") Creating an Array Parentheses are optional here ForEach($url in $i)Iterate through each item in the array Assign $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
41
Notes Page Over-flow Slide. Do Not Print Slide. See Notes pane.
42
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”
43
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
44
Scripts You’ll See Create Web apps, content databases, site collections, and Web sites Create items in a list Activate a feature across multiple site collections Provisioning of managed accounts Back up all site collections in farm
45
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
46
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.
47
Lab B: Administering SharePoint with Stsadm Exercise 1: Executing Stsadm Commands Logon information Estimated time: 20 minutes
48
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.
49
Module Review and Takeaways Review Questions
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.