Download presentation
Presentation is loading. Please wait.
1
Fabian Schenker Consultant Microsoft Schweiz ShowerPoint - PowerShell und SharePoint für die Installation und Management von SharePoint 2010 Farmen Thomas Palmié Architect Microsoft Schweiz
2
Solution Overview PowerShell for SharePoint 2010 Overview Automated Installation of SharePoint 2010 farms Agenda
3
a good understanding about how to automate the provisioning of SharePoint 2010 farms understanding why this is not an option for larger environments Objectives
4
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 file Creating different service application pools Creating different proxy groups Minimal configuration on the servers where we want to install SharePoint Using DBA pre-created databases Setting permissions Executing pre- and post scripts Requirements
5
-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 file http://technet.microsoft.com/en-us/library/cc262839.aspx http://technet.microsoft.com/en-us/library/cc262839.aspx -Clonable SP2010 dev environment: basically for dev. purposes, sysprep, no AD http://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 http://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 PowerShell http://www.microsoft.com/download/en/details.aspx?id=23415 http://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/ http://autospinstaller.codeplex.com/ Existing Solutions
6
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
7
Scripted installation of a SharePoint 2010 farm Solution Overview
8
Slipstream SP 1 bits: sharepointfoundation2010sp1-kb2460058-x64-fullfile-en- us.exe /extract: officeserver2010sp1-kb2460045-x64-fullfile-en-us.exe /extract: 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
9
Pre-Requisites
10
Starting the Installation
11
Automated Farm Installation Provisioning of Service Applications demo…
12
PowerShell for SharePoint 2010 Overview
13
Interact with.NET objects directly Perform administrative functions in bulk, reducing time and effort. Some SharePoint 2010 functions require the use of PowerShell: Resetting the Farm Passphrase How to Reset the Farm Passphrase in SharePoint 2010 Configuring the State Service Application Configuring the Publishing Feature’s Super User Accounts Performance benefits for batch operations Remoting interface SharePoint PowerShell Remoting Requirements SharePoint Remoting with PowerShell 2.0 Benefits of PowerShell
14
Used to find all the commands available to PowerShell Cmdlets 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
15
Used to show Synopsis, Syntax, Description, Parameters, and Examples Several ways to get help information on cmdlets: Get-Help Get-Help Get-SPSite -full Get-Help Get-SPSite -examples Get-Help Get-SPSite –detailed Get-Help *-SPSite -? Help Ex. Help database, Help Get-SPSite, etc. Paging Some results will only show a subset ending with “-- More -- ” = show next line or row = show next page or subset Can create paging by piping results to “more” Get-SPSite | more Get-Help
16
Aliases A way of calling a command using a keyword or abbreviation Most cmdlets have an associated alias to allow for shortcutting Get-Command = gcm Format-List = fl Set-Location = cd Get-ChildItem = dir Use Get-Alias to get a list of aliases available for your current session Use Set-Alias to create your own! Get-Member Gets the properties and methods of objects Get-SPSite | Get-Member Useful for when trying to determine what property you want to output Aliases and Get-Member
17
Still there and still works Remains for backwards compatibility Allows for portability of existing STSADM batch files and scripts Some 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 > STSADM Newly created cmdlets were developed for enhanced performance PowerShell 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?
18
Pipeline Allows output of one cmdlet to be the input of another cmdlet Examples Get-Process | Format-Table Name, CPU Get-SPWebApplication | Get-SPSite | Get-SPWeb Select-Object Allows you to pick available properties instead of grabbing all properties Get-SPSite | Get-SPWeb | Select URL, WebTemplate, LastItemModifiedDate Where-Object Only display results which meet a certain condition Get-SPLogEvent -StartTime (Get-Date).AddMinutes(-5) | Where-Object {$_.Level -eq “High”} Sort-Object Sort the result set by one or more property Get-SPSite | Sort Owner, URL Sort ascending (default) or descending Get-SPSite | Select URL, Owner, LastContentModifiedDate | Sort LastContentModifiedDate -Descending Pipeline, Select, Where, and Sorting
19
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 ] [-AssignmentCollection ] [-Confirm [ ]] [-Filter ] [-Limit ] [-Regex ] [-Site ] [-WhatIf [ ]] [ ] $site = Get-SPSite "http://intranet.contoso.com" $webs = $site | Get-SPWeb $webs = $site.ID | Get-SPWeb $webs = "http://intranet.contoso.com" | Get-SPWeb
20
SharePoint PowerShell examples demo…
21
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-SPShellAdmin Must be local admin, db_owner, and securityadmin to run this command properly User is added to WSS_Admin_WPG group on all WFEs and is added to the SharePoint_Shell_Access role on the database you specified Add-SPShellAdmin -username \ -database Portal_Content_DB If the database switch is not used, then the user is added access to the configuration database Remove-SPShellAdmin Remove-SPShellAdmin -username \ SP2010 PowerShell Permissions
22
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
23
Handling Disposable Items SPAssignmentCollection Collection object that all SharePoint cmdlets can accept to store objects that must be disposed Get-SPSite [-AssignmentCollection ] [-Confirm [ ]] [-Filter ] [- Limit ] [-WebApplication ] [-WhatIf [ ]] [ ]
24
Assignment Collections Start-SPAssignment Start-SPAssignment [-AssignmentCollection ] [-Global ] [ ] Stop-SPAssignment Stop-SPAssignment [-SemiGlobal ] [- AssignmentCollection ] [-Global ] [ ] 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
25
Assignment Collection Example -Global stores items within an internal static variable -SemiGlobal is used for named variables and can be passed via the pipeline
26
Our Solution Automated Installation of SharePoint 2010 farms
27
Option 1: Remote PowerShell PowerShell 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 only Requires that WinRM be enabled on both the client and the server Option 2: Scheduled Tasks Inter Server Communication
28
Usage of Scheduled Tasks
29
Farm Creation Cmdlet NameDescription New-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.
30
Site Structure Creation Cmdlet NameDescription New-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.
31
Service Application Setup/Configuration Cmdlet NameDescription Get-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*ServiceApplication Proxy New-SPServiceApplicationProxyGroup Add-SPServiceApplicationProxyGroupMember Allows service applications to be grouped. Proxy groups are then associated with one or more web applications.
32
Some examples Automated Installation Lessons Learned
33
Creating Service Application Pools New-SPServiceApplicationPool –Name -Account Service Application Pools appears as IIS Application Pool, as soon as a Service Application is created. Creating IIS Application Pools for Web Applications Creating the Application Pool by creating a Web Application. New-SPWebApplication –ApplicationPool -ApplicationPoolAccount -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 IIS Web Application pools but with the "display name" Service Application Pool != IIS Application Pool
34
How to Troubleshoot Scripts that are running using a Scheduled Task? Transcripts! Start-Transcript –Path Stop-Transcript Everything that happens in between is written to a Log File! Remote Troubleshooting
35
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 Account All other Service Application Databases: Owner = Setup Account. Content Databases: Owner = Setup Account Content Databases: Office Web Apps Application Pool Account as db_owner! Database Prestaging
37
Add-PSSnapin SqlServerCmdletSnapin100 Invoke-Sqlcmd –Query «» –ServerInstance -Database
38
State Service Application doesn’t allow prestaged Databases during Configuration of the Service Application. Mount the Database after the Configuration!
39
Let’s have a look at the new provisioned farm demo…
40
PowerShell Command Builder: http://www.microsoft.com/resources/TechNet/en- us/Office/media/WindowsPowerShell/WindowsPowerShellCommandBuilder.html 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 file http://technet.microsoft.com/en-us/library/cc262839.aspx http://technet.microsoft.com/en-us/library/cc262839.aspx Clonable SP2010 dev environment: basically for dev. purposes, sysprep, no AD http://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 http://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 PowerShell http://www.microsoft.com/download/en/details.aspx?id=23415 http://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/ http://autospinstaller.codeplex.com/ Resources
41
Automating SharePoint 2010 with Windows PowerShell 2.0 : http://www.amazon.com/Automating-SharePoint-2010-Windows- PowerShell/dp/0470939206/ref=sr_1_1?s=books&ie=UTF8&qid=1318962412&sr=1-1 http://www.amazon.com/Automating-SharePoint-2010-Windows- PowerShell/dp/0470939206/ref=sr_1_1?s=books&ie=UTF8&qid=1318962412&sr=1-1 Resources
42
Please help us make TechDays even better by Evaluating this Session. Thank you! Give us your feedback!
43
© 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.
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.