The preceding examples show the basic steps
used to provision a new SharePoint 2010 farm. We can automate the
procedure of creating new SharePoint 2010 farm by placing the following
code in a script named New-SPInstallation.ps1.
<#
.SYNOPSIS
Automates a SharePoint 2010 installation.
.DESCRIPTION
The script automates a SharePoint 2010 installation.
Requires that the binaries are installed on the server.
.PARAMETER databaseName
Name of the configuration database.
.PARAMETER databaseServer
Name of the database server.
.PARAMETER centralAdminDatabase
Name of the Central Administration content database.
.PARAMETER port
Port to use.
.PARAMETER windowsAuthProvider
NTLM or Kerberos, default set to NTLM.
.PARAMETER userName
Farm Administrator account in the format 'domain\username'.
.PARAMETER password
Password for the Farm Administrator account.
.PARAMETER passPhrase
Farm password, used to add new machines to the farm.
#>
param(
[string]$databaseName,
[string]$databaseServer,
[string]$centralAdminDatabase,
[string]$port,
[string]$windowsAuthProvider = "NTLM",
[string]$userName,
[string]$password,
[string]$passPhrase
)
# Converting password strings to secure strings
$securePassword = ConvertTo-SecureString -String $password -AsPlainText -Force
$securePassPhrase = ConvertTo-SecureString -String $passPhrase -AsPlainText -Force
# Creating a PSCredential object
$psCredentials =
New-Object -TypeName System.Management.Automation.PSCredential `
-ArgumentList $userName, $securePassword
# New Configuration Database
New-SPConfigurationDatabase -DatabaseName $databaseName `
-DatabaseServer $databaseServer `
-AdministrationContentDatabaseName $centralAdminDatabase `
-Passphrase $securePassPhrase -FarmCredentials $psCredentials
# Install help files
Install-SPHelpCollection -All
# Install services
Install-SPService
# Install Features
Install-SPFeature -AllExistingFeatures
# Create a new Central Administration
New-SPCentralAdministration -Port $port -WindowsAuthProvider $windowsAuthProvider
# Copy shared application data
Install-SPApplicationContent
We can run the script by typing the following:
PS > .\New-SPInstallation.ps1 -databaseName "NimaIntranet_ConfigDB" `
>> -databaseServer "SQLServer01" `
>> -centralAdminDatabase "NimaIntranet_Admin_ContentDB" -port 5057 `
>> -userName "powershell\administrator" `
>> -password "SecretP@ssw0rd" -passPhrase "J0inD0main"
The New-SPInstallation.ps1
script creates a new configuration database and installs the help
collections, the services required, and all existing features. It also
sets up Central Administration and adds shared application content.