43
Fabian Schenker Consultant Microsoft Schweiz ShowerPoint - PowerShell und SharePoint für die Installation und Management von SharePoint 2010 Farmen Thomas Palmié Architect Microsoft Schweiz

Fabian Schenker Consultant Microsoft Schweiz ShowerPoint - PowerShell und SharePoint für die Installation und Management von SharePoint 2010 Farmen Thomas

  • View
    223

  • Download
    3

Embed Size (px)

Citation preview

Page 1: Fabian Schenker Consultant Microsoft Schweiz ShowerPoint - PowerShell und SharePoint für die Installation und Management von SharePoint 2010 Farmen Thomas

Fabian SchenkerConsultantMicrosoft Schweiz

ShowerPoint - PowerShell und SharePoint für die Installation und Management von SharePoint 2010 Farmen

Thomas PalmiéArchitectMicrosoft Schweiz

Page 2: Fabian Schenker Consultant Microsoft Schweiz ShowerPoint - PowerShell und SharePoint für die Installation und Management von SharePoint 2010 Farmen Thomas

Solution OverviewPowerShell for SharePoint 2010 OverviewAutomated Installation of SharePoint 2010 farms

Agenda

Page 3: Fabian Schenker Consultant Microsoft Schweiz ShowerPoint - PowerShell und SharePoint für die Installation und Management von SharePoint 2010 Farmen Thomas

a good understanding about how to automate the provisioning of SharePoint 2010 farmsunderstanding why this is not an option for larger environments

Objectives

Page 4: Fabian Schenker Consultant Microsoft Schweiz ShowerPoint - PowerShell und SharePoint für die Installation und Management von SharePoint 2010 Farmen Thomas

Installation of a SharePoint 2010 farm from one central location (SharePoint, pre-requisites, language packs, service applications) without internet connection using a simple XML config fileCreating different service application poolsCreating different proxy groupsMinimal configuration on the servers where we want to install SharePointUsing DBA pre-created databasesSetting permissions Executing pre- and post scripts

Requirements

Page 5: Fabian Schenker Consultant Microsoft Schweiz ShowerPoint - PowerShell und SharePoint für die Installation und Management von SharePoint 2010 Farmen Thomas

-SPModule: TechNet, uses own Windows PowerShell modules, uses Windows PowerShell remoting, only base installation Config DB and CA, requires internet connection for pre-requisites, no configuration filehttp://technet.microsoft.com/en-us/library/cc262839.aspx -Clonable SP2010 dev environment: basically for dev. purposes, sysprep, no ADhttp://www.joshmeyer.net/blog/post/2010/03/26/Creating-a-cloneable-SharePoint-2010-Development-Environment-with-PowerShell-Windows-Sysprep-and-SQL-Server-2008-R2-Sysprep.aspx -SharePoint easy setup script: for Windows7 installations, native or VHD installation, also for dev. Purposes,requires internet connection, documentation and labs are available,no AD, >2’000 lines of PowerShellhttp://www.microsoft.com/download/en/details.aspx?id=23415 -AutoSPInstaller: PowerShell + XML config file, installs SharePoint and Service Applications, poor documentation,>1’800 lines of Power Shell (one single file!)http://autospinstaller.codeplex.com/

Existing Solutions

Page 6: Fabian Schenker Consultant Microsoft Schweiz ShowerPoint - PowerShell und SharePoint für die Installation und Management von SharePoint 2010 Farmen Thomas

Advantages of our solution:-Clean structure (one file per activity)-Farm provisioning from one central location-Setting permissions-Easy XML configuration-Creates Service Application Pools, Service Applications-Proxy Groups-Offline installation-Language Packs-Office Web Apps

Our Solution

Page 7: Fabian Schenker Consultant Microsoft Schweiz ShowerPoint - PowerShell und SharePoint für die Installation und Management von SharePoint 2010 Farmen Thomas

Scripted installation of a SharePoint 2010 farm

Solution Overview

Page 8: Fabian Schenker Consultant Microsoft Schweiz ShowerPoint - PowerShell und SharePoint für die Installation und Management von SharePoint 2010 Farmen Thomas

Slipstream SP 1 bits:• sharepointfoundation2010sp1-kb2460058-x64-

fullfile-en-us.exe /extract:<some directory>• officeserver2010sp1-kb2460045-x64-fullfile-en-

us.exe /extract:<some directory>• copy all of these extracted files into the “\

Updates” folder of the extracted SharePoint Server 2010 RTM bits

Preparing the Installation

Extracting the .iso file

Provide the Product Keys

Page 9: Fabian Schenker Consultant Microsoft Schweiz ShowerPoint - PowerShell und SharePoint für die Installation und Management von SharePoint 2010 Farmen Thomas

Pre-Requisites

Page 10: Fabian Schenker Consultant Microsoft Schweiz ShowerPoint - PowerShell und SharePoint für die Installation und Management von SharePoint 2010 Farmen Thomas

Starting the Installation

Page 11: Fabian Schenker Consultant Microsoft Schweiz ShowerPoint - PowerShell und SharePoint für die Installation und Management von SharePoint 2010 Farmen Thomas

Automated Farm InstallationProvisioning of Service Applications

demo…

Page 12: Fabian Schenker Consultant Microsoft Schweiz ShowerPoint - PowerShell und SharePoint für die Installation und Management von SharePoint 2010 Farmen Thomas

PowerShell for SharePoint 2010 Overview

Page 13: Fabian Schenker Consultant Microsoft Schweiz ShowerPoint - PowerShell und SharePoint für die Installation und Management von SharePoint 2010 Farmen Thomas

Interact with .NET objects directlyPerform administrative functions in bulk, reducing time and effort.Some SharePoint 2010 functions require the use of PowerShell:

Resetting the Farm PassphraseHow to Reset the Farm Passphrase in SharePoint 2010

Configuring the State Service ApplicationConfiguring the Publishing Feature’s Super User Accounts

Performance benefits for batch operationsRemoting interface

SharePoint PowerShell Remoting RequirementsSharePoint Remoting with PowerShell 2.0

Benefits of PowerShell

Page 14: Fabian Schenker Consultant Microsoft Schweiz ShowerPoint - PowerShell und SharePoint für die Installation und Management von SharePoint 2010 Farmen Thomas

Used to find all the commands available to PowerShellCmdlets generally have a verb-noun naming convention

Get-ChildItem, Get-Member, Add-SPSolution, Backup-SPFarm, Export-SPWeb

Get-Command -noun *infopath*Get-Command -noun *solution*List all available SP2010 cmdlets:

Get-Command -PSSnapin “Microsoft.SharePoint.PowerShell”

Get-Command

Page 15: Fabian Schenker Consultant Microsoft Schweiz ShowerPoint - PowerShell und SharePoint für die Installation und Management von SharePoint 2010 Farmen Thomas

Used to show Synopsis, Syntax, Description, Parameters, and ExamplesSeveral ways to get help information on cmdlets:

Get-Help <cmdlet>Get-Help Get-SPSite -fullGet-Help Get-SPSite -examplesGet-Help Get-SPSite –detailedGet-Help *-SPSite

<cmdlet> -?Help <name>

Ex. Help database, Help Get-SPSite, etc.

PagingSome results will only show a subset ending with “-- More --”<ENTER> = show next line or row<SPACE> = show next page or subsetCan create paging by piping results to “more”

Get-SPSite | more

Get-Help

Page 16: Fabian Schenker Consultant Microsoft Schweiz ShowerPoint - PowerShell und SharePoint für die Installation und Management von SharePoint 2010 Farmen Thomas

AliasesA way of calling a command using a keyword or abbreviationMost cmdlets have an associated alias to allow for shortcutting

Get-Command = gcmFormat-List = flSet-Location = cdGet-ChildItem = dir

Use Get-Alias to get a list of aliases available for your current sessionUse Set-Alias to create your own!

Get-MemberGets the properties and methods of objects

Get-SPSite | Get-MemberUseful for when trying to determine what property you want to output

Aliases and Get-Member

Page 17: Fabian Schenker Consultant Microsoft Schweiz ShowerPoint - PowerShell und SharePoint für die Installation und Management von SharePoint 2010 Farmen Thomas

Still there and still worksRemains for backwards compatibilityAllows for portability of existing STSADM batch files and scriptsSome commands have been removed (ex. all SSP related commands)

You should start to do everything in PowerShell!Remember that it’s the “14 Hive” now

C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\BIN

PowerShell > STSADMNewly created cmdlets were developed for enhanced performancePowerShell has full access to the SharePoint API from the command line

STSADM to Windows PowerShell Mapping:http://technet.microsoft.com/en-us/library/ff621081.aspx

STSADM?

Page 18: Fabian Schenker Consultant Microsoft Schweiz ShowerPoint - PowerShell und SharePoint für die Installation und Management von SharePoint 2010 Farmen Thomas

PipelineAllows output of one cmdlet to be the input of another cmdletExamples

Get-Process | Format-Table Name, CPUGet-SPWebApplication | Get-SPSite | Get-SPWeb

Select-ObjectAllows you to pick available properties instead of grabbing all propertiesGet-SPSite | Get-SPWeb | Select URL, WebTemplate, LastItemModifiedDate

Where-ObjectOnly display results which meet a certain conditionGet-SPLogEvent -StartTime (Get-Date).AddMinutes(-5) | Where-Object {$_.Level -eq “High”}

Sort-ObjectSort the result set by one or more property

Get-SPSite | Sort Owner, URLSort ascending (default) or descending

Get-SPSite | Select URL, Owner, LastContentModifiedDate | Sort LastContentModifiedDate -Descending

Pipeline, Select, Where, and Sorting

Page 19: Fabian Schenker Consultant Microsoft Schweiz ShowerPoint - PowerShell und SharePoint für die Installation und Management von SharePoint 2010 Farmen Thomas

PipeBind Objects

Allows different representations of an artifact to be passed into cmdlets

Example: SPSitePipeBind accepts either a GUID, URL, or SPSite object

Get-SPWeb [-Identity <SPWebPipeBind>] [-AssignmentCollection <SPAssignmentCollection>] [-Confirm [<SwitchParameter>]] [-Filter <ScriptBlock>] [-Limit <String>] [-Regex <SwitchParameter>] [-Site <SPSitePipeBind>] [-WhatIf [<SwitchParameter>]] [<CommonParameters>]

$site = Get-SPSite "http://intranet.contoso.com"$webs = $site | Get-SPWeb$webs = $site.ID | Get-SPWeb$webs = "http://intranet.contoso.com" | Get-SPWeb

Page 20: Fabian Schenker Consultant Microsoft Schweiz ShowerPoint - PowerShell und SharePoint für die Installation und Management von SharePoint 2010 Farmen Thomas

SharePoint PowerShell examples

demo…

Page 21: Fabian Schenker Consultant Microsoft Schweiz ShowerPoint - PowerShell und SharePoint für die Installation und Management von SharePoint 2010 Farmen Thomas

Out-of-the-box only the Farm Account has permission to interact with SharePoint 2010 via PowerShell. This does not include additional Farm Administrators.Get-SPShellAdmin

Lists who has rights to run PowerShell commands against the databases

Add-SPShellAdminMust be local admin, db_owner, and securityadmin to run this command properlyUser is added to WSS_Admin_WPG group on all WFEs and is added to the SharePoint_Shell_Access role on the database you specifiedAdd-SPShellAdmin -username <domain>\<user> -database Portal_Content_DB

If the database switch is not used, then the user is added access to the configuration database

Remove-SPShellAdminRemove-SPShellAdmin -username <domain>\<user>

SP2010 PowerShell Permissions

Page 22: Fabian Schenker Consultant Microsoft Schweiz ShowerPoint - PowerShell und SharePoint für die Installation und Management von SharePoint 2010 Farmen Thomas

PowerShell Threading

Default behavior (V1 & V2): Each line, function, or script runs in it’s own thread

$host.Runspace.ThreadOptions == "Default"Causes memory leaks with unreleased handles to unmanaged objects

Management Shell: Each line, function, or script runs in the same thread

$host.Runspace.ThreadOptions == "ReuseThread"Still has potential for memory leaks but impact is much less

Page 23: Fabian Schenker Consultant Microsoft Schweiz ShowerPoint - PowerShell und SharePoint für die Installation und Management von SharePoint 2010 Farmen Thomas

Handling Disposable Items

SPAssignmentCollectionCollection object that all SharePoint cmdlets can accept to store objects that must be disposed

Get-SPSite [-AssignmentCollection <SPAssignmentCollection>] [-Confirm [<SwitchParameter>]] [-Filter <ScriptBlock>] [-Limit <String>] [-WebApplication <SPWebApplicationPipeBind>] [-WhatIf [<SwitchParameter>]] [<CommonParameters>]

Page 24: Fabian Schenker Consultant Microsoft Schweiz ShowerPoint - PowerShell und SharePoint für die Installation und Management von SharePoint 2010 Farmen Thomas

Assignment CollectionsStart-SPAssignment

Start-SPAssignment [-AssignmentCollection <SPAssignmentCollection>] [-Global <SwitchParameter>] [<CommonParameters>]

Stop-SPAssignmentStop-SPAssignment [-SemiGlobal <SPAssignmentCollection>] [-AssignmentCollection <SPAssignmentCollection>] [-Global <SwitchParameter>] [<CommonParameters>]

Three levels of assignment:No assignment (dispose immediately)Simple assignment (use a global store)Advanced assignment (use a named store)

Only Get-SPSite, Get-SPWeb, New-SPSite, and New-SPWeb use this disposal capability

Page 25: Fabian Schenker Consultant Microsoft Schweiz ShowerPoint - PowerShell und SharePoint für die Installation und Management von SharePoint 2010 Farmen Thomas

Assignment Collection Example-Global stores items within an internal static variable-SemiGlobal is used for named variables and can be passed via the pipeline

Page 26: Fabian Schenker Consultant Microsoft Schweiz ShowerPoint - PowerShell und SharePoint für die Installation und Management von SharePoint 2010 Farmen Thomas

Our Solution

Automated Installation of SharePoint 2010 farms

Page 27: Fabian Schenker Consultant Microsoft Schweiz ShowerPoint - PowerShell und SharePoint für die Installation und Management von SharePoint 2010 Farmen Thomas

Option 1: Remote PowerShellPowerShell Remoting uses WinRM, Microsoft’s implementation of the WS-Management protocol

WinRM allows you to run scripts against remote servers over HTTP and HTTPS

Works with V2 onlyRequires that WinRM be enabled on both the client and the server

Option 2: Scheduled Tasks

Inter Server Communication

Page 28: Fabian Schenker Consultant Microsoft Schweiz ShowerPoint - PowerShell und SharePoint für die Installation und Management von SharePoint 2010 Farmen Thomas

Start installation

Create C:\Temp folder and copy required files

Activity 1 in Initialize.ps

1

Create «Scheduled Task» and wait for specific file

write file when finished

Activity n in Initialize.ps

1

Create «Scheduled Task» and wait for specific file

write file when finished

Usage of Scheduled Tasks

Page 29: Fabian Schenker Consultant Microsoft Schweiz ShowerPoint - PowerShell und SharePoint für die Installation und Management von SharePoint 2010 Farmen Thomas

Farm CreationCmdlet Name DescriptionNew-SPConfigurationDatabase Creates a new configuration database, and therefore a new SharePoint

farm. This cmdlet is run only once per farm.Connect-SPConfigurationDatabase Connects a server to an existing configuration database thus adding the

server to the farm. This cmdlet is run once per server in the farm after the first server is provisioned using New-SPConfigurationDatabase.

Initialize-SPResourceSecurity Sets required file, folder, and registry ACLs for the local server. This cmdlet must be run for each server in the farm.

Install-SPService Installs the services in the farm. This cmdlet is run once per farm (in a standalone configuration it is possible to automatically provision the services by running the cmdlet again, providing the –Provision parameter) :

PS C:\> Install-SPService

Install-SPFeature Installs all the Features available to the farm. This cmdlet is run once per farm using the -AllExistingFeatures parameter:

PS C:\> Install-SPFeature -AllExistingFeatures

New-SPCentralAdministration Provisions a central administration site on the local server. This cmdlet is typically run only once per farm but can be run on additional servers as is needed.

Install-SPHelpCollection This optional cmdlet installs the help files that are used throughout the farm. This cmdlet is run only once per farm on the same server as the central admin site unless installing new help collections (custom or third party). Provide the -All switch when calling this cmdlet for Farm setup.

PS C:\> Install-SPHelpCollection -All

Install-SPApplicationContent This optional cmdlet installs any application content for the central administration site. This cmdlet is run only once per farm on the same server as the central administration site.

Page 30: Fabian Schenker Consultant Microsoft Schweiz ShowerPoint - PowerShell und SharePoint für die Installation und Management von SharePoint 2010 Farmen Thomas

Site Structure CreationCmdlet Name DescriptionNew-SPManagedAccount Creates a new managed account which can be used when creating the

application pool.

New-SPWebApplication Creates a new web application.

New-SPContentDatabase Creates a new content database for a specific web application.

New-SPManagedPath Creates a managed path under the specified web application.

New-SPSite Creates a new Site Collection (watch for disposal issues!)

New-SPWeb Creates a new Site within a Site Collection (watch for disposal issues!)

Set-SPDesignerSettings Sets the actions that users can perform using SharePoint Designer.

Page 31: Fabian Schenker Consultant Microsoft Schweiz ShowerPoint - PowerShell und SharePoint für die Installation und Management von SharePoint 2010 Farmen Thomas

Service Application Setup/Configuration

Cmdlet Name DescriptionGet-SPServiceInstance Returns back the service instances installed on the server. Use this

cmdlet to check if a service instance is online prior to enabling.$svc = (Get-SPServiceInstance | Where {$_.TypeName -eq "Managed Metadata Web Service"})

Start-SPServiceInstance The actual service instance. For most services this can be called on more than one server to provide failover and load balancing.if ($svc.Status –eq "Disabled") { $svc | Start-SPServiceInstance}while($svc.Status -ne "Online") { Write-Host -ForegroundColor Yellow "Waiting for Metadata service to provision"; sleep 5;}

New-SP*ServiceApplication Defines the actual service definition and configurations for a service instance. Most service applications allow multiple instances per farm with different configurations and proxy group associations.PS C:\> Get-Command New-SP*ServiceApplication

New-SP*ServiceApplicationProxy The “service connection” that allows communication with the service application. It is only necessary to run this once per service application.PS C:\> Get-Command New-SP*ServiceApplicationProxy

New-SPServiceApplicationProxyGroupAdd-SPServiceApplicationProxyGroupMember

Allows service applications to be grouped. Proxy groups are then associated with one or more web applications.

Page 32: Fabian Schenker Consultant Microsoft Schweiz ShowerPoint - PowerShell und SharePoint für die Installation und Management von SharePoint 2010 Farmen Thomas

Some examples

Automated Installation Lessons Learned

Page 33: Fabian Schenker Consultant Microsoft Schweiz ShowerPoint - PowerShell und SharePoint für die Installation und Management von SharePoint 2010 Farmen Thomas

Creating Service Application PoolsNew-SPServiceApplicationPool –Name <String> -Account <SPProcessAccountPipeBind>Service Application Pools appears as IIS Application Pool, as soon as a Service Application is created.

Creating IIS Application Pools for Web ApplicationsCreating the Application Pool by creating a Web Application.New-SPWebApplication –ApplicationPool <String> -ApplicationPoolAccount <SPProcessAccountPipeBind> -Name….If the Application Pool exists: -ApplicationPoolAccount is not allowed!If the Application Pool doesn’t exist: -ApplicationPoolAccount is required.

there is no relationship between the Service Application Pools and Web Application Pools

Service application pools are created as a GUID in IISWeb Application pools but with the "display name"

Service Application Pool != IIS Application Pool

Page 34: Fabian Schenker Consultant Microsoft Schweiz ShowerPoint - PowerShell und SharePoint für die Installation und Management von SharePoint 2010 Farmen Thomas

How to Troubleshoot Scripts that are running using a Scheduled Task?Transcripts!Start-Transcript –PathStop-TranscriptEverything that happens in between is written to a Log File!

Remote Troubleshooting

Page 35: Fabian Schenker Consultant Microsoft Schweiz ShowerPoint - PowerShell und SharePoint für die Installation und Management von SharePoint 2010 Farmen Thomas

Questions:Naming?Size and Growth?How many Datafiles?Location of Log and Datafiles?

Think about those Questions during the engineering phase!Don’t let SharePoint create your Databases!Security for prestaged Databases:

BDC & Secure Store Service Databases: Owner = Farm AccountAll other Service Application Databases: Owner = Setup Account.Content Databases: Owner = Setup AccountContent Databases: Office Web Apps Application Pool Account as db_owner!

Database Prestaging

Page 36: Fabian Schenker Consultant Microsoft Schweiz ShowerPoint - PowerShell und SharePoint für die Installation und Management von SharePoint 2010 Farmen Thomas

Database Prestaging

Page 37: Fabian Schenker Consultant Microsoft Schweiz ShowerPoint - PowerShell und SharePoint für die Installation und Management von SharePoint 2010 Farmen Thomas

Add-PSSnapin SqlServerCmdletSnapin100Invoke-Sqlcmd –Query «» –ServerInstance -Database

Database PrestagingAdd a User to a Database using Windows PowerShell

Page 38: Fabian Schenker Consultant Microsoft Schweiz ShowerPoint - PowerShell und SharePoint für die Installation und Management von SharePoint 2010 Farmen Thomas

State Service Application doesn’t allow prestaged Databases during Configuration of the Service Application.Mount the Database after the Configuration!

Database PrestagingState Service Application

Page 39: Fabian Schenker Consultant Microsoft Schweiz ShowerPoint - PowerShell und SharePoint für die Installation und Management von SharePoint 2010 Farmen Thomas

Let’s have a look at the new provisioned farm

demo…

Page 40: Fabian Schenker Consultant Microsoft Schweiz ShowerPoint - PowerShell und SharePoint für die Installation und Management von SharePoint 2010 Farmen Thomas

PowerShell Command Builder:http://www.microsoft.com/resources/TechNet/en-us/Office/media/WindowsPowerShell/WindowsPowerShellCommandBuilder.html

SPModule: TechNet, uses own Windows PowerShell modules, uses Windows PowerShell remoting, only base installation Config DB and CA, requires internet connection for pre-requisites, no configuration filehttp://technet.microsoft.com/en-us/library/cc262839.aspx

Clonable SP2010 dev environment: basically for dev. purposes, sysprep, no ADhttp://www.joshmeyer.net/blog/post/2010/03/26/Creating-a-cloneable-SharePoint-2010-Development-Environment-with-PowerShell-Windows-Sysprep-and-SQL-Server-2008-R2-Sysprep.aspx

SharePoint easy setup script: for Windows7 installations, native or VHD installation, also for dev. Purposes,requires internet connection, documentation and labs are available,no AD, >2’000 lines of PowerShellhttp://www.microsoft.com/download/en/details.aspx?id=23415

AutoSPInstaller: PowerShell + XML config file, installs SharePoint and Service Applications, poor documentation,>1’800 lines of Power Shell (one single file!)http://autospinstaller.codeplex.com/

Resources

Page 42: Fabian Schenker Consultant Microsoft Schweiz ShowerPoint - PowerShell und SharePoint für die Installation und Management von SharePoint 2010 Farmen Thomas

Please help us make TechDays even better by Evaluating this Session. Thank you!

Give us your feedback!

Page 43: Fabian Schenker Consultant Microsoft Schweiz ShowerPoint - PowerShell und SharePoint für die Installation und Management von SharePoint 2010 Farmen Thomas

© 2011 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries.

The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after

the date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.