Utilizing PowerShell to Deploy SharePoint 2010

Add a comment January 31st, 2011

Standardization of SharePoint 2010 deployments are important to me, especially within the DoD. It’s my belief that standardization could minimize environmental issues while giving all of us engineers a baseline understanding of how farms have been deployed in common environments, reducing spin up to final resolution times. The use of PowerShell allows us to do this without having to rely on the user to click or not click something which lets face it, sometimes we can’t rely on ourselves to click the right thing every time, so we can’t expect it from anyone else. So let’s look at how we can install SharePoint 2010 using a script and deploy the farm using PowerShell:

I recommend following a previous blog post before implementing the steps below to insure you have prepared your operating system for SharePoint 2010:

Preparing W2K8 for SharePoint 2007/2010 Installation.

Install SharePoint 2010 PreReqs:

For each of the servers in the farm (SPAPPSVR, SPIDX, SPWFE1, and SPWFE2):

  1. Create a folder named SP2010_Build on your D:\
  2. Inside the SP2010_Build folder, create 2 more folders named Products and another named Scripts.
  3. Inside the Products folder, create another folder named SharePoint_2010_Installation.
  4. Copy your SharePoint 2010 RTM files and any updates into the D:\SP2010_Build\Products\SharePoint_2010_Installation folder.
  5. Download the SP2010_PreReq.iso file.
  6. Mount the ISO file to your operating system or burn them to a CD.
  7. Copy the folder named PrerequisiteInstallerFiles to the D:\SP2010_Build\Products\SharePoint_2010_Installation folder.
  8. Copy the file named PrerequisiteInstaller.Arguments.txt file to the D:\SP2010_Build\Products\SharePoint_2010_Installation folder.
  9. Copy the file Prereq_SP2010.cmd to the D:\SP2010_Build\Scripts\ folder.
  10. Execute Prereq_SP2010.cmd from command prompt so that you can view the output:
  11.  

    Restart Server(s)

    SharePoint 2010 Installation

    The following steps will be performed on every SharePoint 2010 server.

  12. Create a file named “InstallAndConfigSP2010_rtm.xml” inside of D:\SP2010_Build\Scripts and paste the following script within it:
  13. On line 12 of the above script, don’t forget to put your SharePoint 2010 Product Key. =o)
  14. Create a file named “Install_SP2010.cmd” inside of D:\SP2010_Build\Scripts and paste the following within it:
  15. @ECHO OFF
    echo.
    
    D:\SP2010_Build\Products\SharePoint_2010_Installation\setup.exe /config D:\SP2010_Build\Scripts\InstallAndConfigSP2010_rtm.xml
    exit /b 0
  16. Execute “Install_SP2010.cmd” from command prompt so that you can view the output:
  17.  **NOTE**

    The SharePoint 2010 installation does not show any information in the command prompt. The curson will continue to blink until the install is complete. The method to determine whether the installation is proceeding properly is to locate the installation log file located at: %temp%\SharePoint Server Setup(date_string).log

    Create SharePoint 2010 Farm

  18. Create a file named “Create_SP2010Farm.ps1” inside of D:\SP2010_Build\Scripts and paste the following within it:
  19. Set-ExecutionPolicy unrestricted
    ## Settings you may want to change ##
    $err = $null
    $SetupPath         = "D:\SP2010_Build\Products\SharePoint_2010_Installation"
    $user              = "DOMAIN\FARM_ADMIN_SERVICE_ACCOUNT"
    $password          = ConvertTo-SecureString "FARM_ADMIN_SERVICE_ACCOUNT_PASSWORD" -AsPlainText –Force
    $FarmCredential    = new-object -typename System.Management.Automation.PSCredential -argumentlist $user, $password
    $DBServer          = "SQL_SERVER_NAME\SQL_SERVER_INSTANCE"
    $AdminContentDB    ="SharePoint_Admin_Content"
    $Passphrase        = ConvertTo-SecureString "FARM_ADMIN_SERVICE_ACCOUNT_PASSWORD" -AsPlainText –Force
    $FarmName          = Your_Farm_Name"
    $CAPort            = "25000"
    
    ## Here is the script to install SharePoint Foundation 2010 and create Central Admin ##
    
            Add-PSSnapin Microsoft.SharePoint.PowerShell -erroraction SilentlyContinue
            Write-Host "[4/12] Creating new configuration database..."
            New-SPConfigurationDatabase -DatabaseName ("{0}_SharePoint_Configuration_DB" -f $FarmName) -DatabaseServer $DBServer -AdministrationContentDatabaseName ("{0}_AdminContent_DB" -f $FarmName) -FarmCredentials $FarmCredential -Passphrase $Passphrase -ErrorVariable err
            Write-Host "[5/12] Verifying farm creation..."
            $spfarm = get-spfarm
                if ($spfarm -ne $null) {
                Write-Host "[6/12] ACLing SharePoint Resources..."
                Initialize-SPResourceSecurity -ErrorVariable err
                if ([String]::IsNullOrEmpty($err) -eq $true) {
                    Write-Host "[7/12] Installing Services..."
                    Install-SPService -ErrorVariable err
                        #if ([String]::IsNullOrEmpty($err) -eq $true) {
                        Write-Host "[8/12] Installing Features..."
                        Install-SPFeature -AllExistingFeatures -ErrorVariable err
                        if ([String]::IsNullOrEmpty($err) -eq $true) {
                            Write-Host "[9/12] Provisioning Central Administration..."
                            New-SPCentralAdministration -Port $CAPort -WindowsAuthProvider "NTLM" -ErrorVariable err
                            if ([String]::IsNullOrEmpty($err) -eq $true) {
                                Write-Host "[10/12] Installing Help..."
                                Install-SPHelpCollection -All -ErrorVariable err
                                if ([String]::IsNullOrEmpty($err) -eq $true) {
                                    Write-Host "[11/12] Installing Application Content..."
                                    Install-SPApplicationContent -ErrorVariable err
                                    if ([String]::IsNullOrEmpty($err) -eq $true) {
                                        Write-Host "[12/12] Basic configuration completed."
                                    } else { Write-Error "ERROR: $err" }
                                } else { Write-Error "ERROR: $err" }
                            } else { Write-Error "ERROR: $err" }
                        } else { Write-Error "ERROR: $err" }
                    } else { Write-Error "ERROR: $err" }
                } else { Write-Error "ERROR: $err" }
             } else { Write-Error "ERROR: $err" }
  20. Run the Create_SP2010Farm.ps1 PowerShell script on your designated Central Administration server (App or Index server, we do not recommend using a WFE for the CA).
  21. Please edit the lines 5, 6, 7, 8, 9, 10, 11, and 12 of the above script to reflect your desired configuration settings.
  22. Open PowerShell and the run the script, monitor the output for any errors.
  23. If the configuration is a success, the Central Administration web site should now be accessible.

    Join Subsequent Server to the Farm

    Create a file named “Join_SP2010Farm.ps1” inside of D:\SP2010_Build\Scripts and paste the following within it:

    Set-ExecutionPolicy unrestricted
    ## Settings you may want to change ##
    $err = $null
    $SetupPath         = "D:\SP2010_Build\Products\SharePoint_2010_Installation"
    $user              = "DOMAIN\FARM_ADMIN_SERVICE_ACCOUNT"
    $password          = ConvertTo-SecureString "FARM_ADMIN_SERVICE_ACCOUNT_PASSWORD" -AsPlainText –Force
    $FarmCredential    = new-object -typename System.Management.Automation.PSCredential -argumentlist $user, $password
    $DBServer          = "SQL_SERVER_NAME\SQL_SERVER_INSTANCE"
    $Passphrase        = ConvertTo-SecureString "FARM_ADMIN_SERVICE_ACCOUNT_PASSWORD" -AsPlainText –Force
    $FarmName          = Your_Farm_Name"
    $CAPort            = "25000"
    
    ## Here is the script to create Central Admin ##
    
            Add-PSSnapin Microsoft.SharePoint.PowerShell -erroraction SilentlyContinue
            Write-Host "[4/12] Connecting to configuration database..."
            Connect-SPConfigurationDatabase -DatabaseName ("{0}_SharePoint_Configuration_DB" -f $FarmName) -DatabaseServer $DBServer -Passphrase $Passphrase
            Write-Host "[5/12] Verifying farm creation..."
            $spfarm = get-spfarm
                if ($spfarm -ne $null) {
                Write-Host "[6/12] ACLing SharePoint Resources..."
                Initialize-SPResourceSecurity -ErrorVariable err
                if ([String]::IsNullOrEmpty($err) -eq $true) {
                    Write-Host "[7/12] Installing Services..."
                    Install-SPService -ErrorVariable err
                        if ([String]::IsNullOrEmpty($err) -eq $true) {
                        Write-Host "[8/12] Installing Features..."
                        Install-SPFeature -AllExistingFeatures -ErrorVariable err
                        if ([String]::IsNullOrEmpty($err) -eq $true) {
                            Write-Host "[9/12] Provisioning Central Administration..."
                            if ([String]::IsNullOrEmpty($err) -eq $true) {
                                Write-Host "[10/12] Installing Help..."
                                Install-SPHelpCollection -All -ErrorVariable err
                                if ([String]::IsNullOrEmpty($err) -eq $true) {
                                    Write-Host "[11/12] Installing Application Content..."
                                    Install-SPApplicationContent -ErrorVariable err
                                    if ([String]::IsNullOrEmpty($err) -eq $true) {
                                        Write-Host "[12/12] Basic configuration completed."
                                    } else { Write-Error "ERROR: $err" }
                                } else { Write-Error "ERROR: $err" }
                            } else { Write-Error "ERROR: $err" }
                        } else { Write-Error "ERROR: $err" }
                    } else { Write-Error "ERROR: $err" }
                } else { Write-Error "ERROR: $err" }
            } else { Write-Error "ERROR: $err" }
        net start sptimerv4
  24. Please edit the lines 5, 6, 8, 9, 10, and 11 of the above script to reflect your desired configuration settings.
  25. Run the Create_SP2010Farm.ps1 PowerShell script on your designated Central Administration server (App or Index server, we do not recommend using a WFE for the CA).
  26. Open PowerShell and the run the script, monitor the output for any
    errors

  1. September 9th, 2014 at 05:13 | #1

    I read a lot of interesting articles here.
    Probably you spend a lot of time writing, i know how to save you a lot of work, there
    is an online tool that creates high quality, google friendly articles in seconds,
    just search in google – k2seotips unlimited content

  2. October 7th, 2016 at 19:43 | #2

    A motivating discussion is wortth ϲomment. Ι do tһink that уou ѕhould
    publish more abⲟut thiѕ topic, it may not be a taboo
    subject but uѕually people do not talok about ѕuch topics.
    Тo thе next! Αll the best!!

  1. No trackbacks yet.
Comments feed