1 / 17

Building your SharePoint Farm with PowerShell

Building your SharePoint Farm with PowerShell. Bill Brockbank Solution Architect – SharePoint MVP Navantis Inc. http:// blog.billbrockbank.net Brian Lalancette Infrastructure Consultant Navantis Inc. TSBUG – March 16 th 2011. What is Windows PowerShell?.

mariah
Télécharger la présentation

Building your SharePoint Farm with PowerShell

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Building your SharePoint Farm with PowerShell Bill BrockbankSolution Architect – SharePoint MVP Navantis Inc. http://blog.billbrockbank.netBrian LalancetteInfrastructure Consultant Navantis Inc. TSBUG – March 16th 2011

  2. What is Windows PowerShell? • An interactive command-line and task-based scripting technology. • Allows IT professionals to accelerate automation of tasks. • What about developers (or IT Pro Developers) • A single mindset for management of many different systems (e.g.: AD, Exchange, Windows and now SharePoint) • Via PowerShell Module • Extensible framework that can be embedded inside other applications – not just a command line replacement!

  3. Welcome to SharePoint PowerShellThe History • SharePoint v1/v2 (2001-2003): • No command-line interface • SharePoint 2007: • STSADM: 182 Commands (MOSS) • There are some community support (Gary Lapointe)but this was just away to access the SharePoint OM. • SharePoint 2010 • 652 PowerShell cmdlets • Superset of Administration UI* • Extensible Platform • In-line Discoverability • Optimized for Batch Operations • No support for Installing the bits

  4. Why PowerShellSpeed and Style Deal with the .NET objects directly (Any) Remoting support to your SharePoint Services Performance benefits for batch operations STSADM Batch Operation PowerShell Cmdlets in Batch Start Thread New STSADM Execution Start Thread Load DLLs Start logging Repeat Start Logging Execute Command Repeat Execute Command Stop logging Stop Logging Stop Thread Close STSADM & Thread

  5. SharePoint PowerShellBasics • Cmdlets for “Getting, Creating, Configuring” various SharePoint Objects. For e.g.: • Sites, Site Collections, Web Applications, Service Applications and related commands • PipeBinds for “getting a unique object” • Examples: • SPSitePipeBind: GUID, URL, or SPSite Object are all accepted • SPContentDatabasePipeBind: GUID, Name, or SPContentDatabase

  6. DemoPowerShell “Remoting”

  7. PowerShellRemoting • New in PowerShell V2 – Support via WinRM • Supporting in Windows Server 2008 R2 and Windows 7 • A remote interaction involves 2 endpoints – Client and a Server • PowerShell depends on WinRM for transport of data between endpoints

  8. PowerShell “Remoting” and SharePoint • Windows PowerShell Remoting needs to be enabled first • Windows PowerShell Remoting needs to be enabled first by calling the following cmdlet in Windows PowerShell: • Enable-PSRemoting • You MUST use CredSSP authentication. • To enable CredSSP on the server, use the following command: • Enable-WSManCredSSP –Role Server • To enable CredSSP on the client, use the following command: • Enable-WSManCredSSP -Role client -DelegateComputer* • Increase the MaxMemoryPerShellMB value on the remote boxes which essentially limits the amount of memory that any single remote process can use. • Set-Item WSMan:\localhost\Shell\MaxMemoryPerShellMB 1000

  9. PowerShell Modules • Microsoft has add several PowerShell Modules with Windows Server 2008 R2. • Get-Modules –ListAvaible • ADRM – Microsoft Windows Active Directory Rights Management Services Module • BestPractices – Best Practices Analyzer (BPA) • BitsTransfer –Background Intelligent Transfer Management (BITS) • ServerManger – Server Manager module • TroubleshootingPack –Microsoft Windows Troubleshooting Pack Module • WebAdministration – Web Server Administration module • ImportSystemModules – will load all of the Modules into PowerShell • gcm –module <Module name> • Example: gcm –module ServerManager • cmdlet Add-WindowsFeature • cmdletGet-WindowsFeature • cmdletRemove-WindowsFeature

  10. PowerShellSPModule for SharePoint • SPModule written by members of the SharePoint Product Group in our spare time. • Downloaded form Microsoft Download site. • The SPModule files are a sample Windows PowerShell module related to farm installation. • Not more PowerShellcmdlet’s for SharePoint • SPModule: Is a collection of PowerShellfunctions • 2 PowerShell Modules with 18 function: • SPMosule.Misc (9) • SPModule.Setup (9) Install-SharePoint, New-SharePointFarm,Join-SharePointFarm, ….

  11. How To Use SPModule • Importing it, this can be done before you install SharePoint on the server and it cam be do remotely. • Import Spmodule in to PowerShell • $env:PSModulePath = “C:\SPModule;” + $env:PSModulePath • Import-ModuleSPModule.misc • Import-ModuleSPModule.setup • Executing SPModule functions: • Install-SharePoint-SetupExePath “\\servername\SharePoint2010-Beta\setup.exe” -PIDKey “PKXTJ-DCM9D-6MM3V-G86P8-MJ8CY” • New-SharePointFarm–DatabaseAccessAccount (Get-Credential DOMAIN\username) –DatabaseServer “SQL01” –FarmName“TestFarm” • Join-SharePointFarm-DatabaseServer “SQL01” -ConfigurationDatabaseName “TestFarm_SharePoint_Configuration_Database” • Backup-Logs-outp “$env:userprofile\Desktop\SharePointLogs.zip”

  12. “Remoting” - SPModule • One you have enable the server and clients, you can now connect to the from the client to your servers. • Connect to the remote server “sp2010-few” the thespinst user account, you will be prompted for the accounts password. • Enter-PSSession-ComputerName sp2010-few -Authentication CredSSP-Credential $Env:USERDOMAIN\spinst • Run a script on the server – in this case it imports SPModule and runs the Install-SharePoint function • . 'C:\Software\SharePoint Build Scripts\InstallSP2010Server.ps1‘ • Close the remote session • Exit-PSSession

  13. IntallSP2010Server.ps1 script • Set-ExecutionPolicy -ExecutionPolicyBypass • # Import SPModule's • $env:PSModulePath = "C:\Software\SharePoint Build Scripts\SPModule;" + $env:PSModulePath • Import-Module SPModule.misc • Import-Module SPModule.setup • $InstallDirectory = "C:\Microsoft SharePoint Servers\14.0\" • $SetupExePath = "C:\Software\SharePoint Server 2010\" • $DataDirectory = $InstallDirectory + "Data" • # SharePoint Server 2010 Product Key • $PKEY = “AAAAA-12345-XTXT1-22222-BPX4E" • Install-SharePoint -InstallDirectory $InstallDirectory -DataDirectory $DataDirectory -SetupExePath $SetupExePath -PIDKey $PKEY

  14. DemoSharePoint SPModule

  15. Referrences • Zach RosenfieldBlog http://sharepoint.microsoft.com/Blogs/zach/default.aspx • Signing Your PowerShell Scripts http://sharepoint.microsoft.com/blogs/zach/Lists/Posts/Post.aspx?ID=53 • SPModule.HelloWorld() http://sharepoint.microsoft.com/blogs/zach/Lists/Posts/Post.aspx?ID=54 • Windows PowerShell Remotinghttp://msdn.microsoft.com/en-us/library/ee706585(VS.85).aspx • SharePoint 2010 with Windows PowerShell Remoting Step by Step http://blogs.msdn.com/b/opal/archive/2010/03/07/sharepoint-2010-with-windows-powershell-remoting-step-by-step.aspx

  16. More Referrences • SharePoint PowerShell “Remoting” Requirements http://sharepoint.microsoft.com/blogs/zach/Lists/Posts/Post.aspx?ID=45 • SPModuleDownload http://www.microsoft.com/downloads/en/details.aspx?displaylang=en&FamilyID=c57556ff-8df0-44fd-aba6-3df01b9f80ce • AutoSPInstallerhttp://autospinstaller.codeplex.com/

  17. AutoSPinstaler (Brian Lalancette)

More Related