For information about how to manually deploy SharePoint Server 2010 on a single server, see Deploy a single server with a built-in database (SharePoint Server 2010) or Deploy a single server with SQL Server (SharePoint Server 2010).
Deploy SharePoint Server 2010 by using Windows PowerShell scripts
You can use Windows PowerShell scripts to deploy SharePoint Server 2010 on a single server.
As a best practice, you should not run unsigned scripts.
For more information about signing Windows PowerShell scripts, see Windows PowerShell:
Sign Here Please (http://go.microsoft.com/fwlink/?linkid=160357) in TechNet Magazine. For more information about code signing in general, see Introduction to Code Signing
(http://go.microsoft.com/fwlink/?linkid=59273) on MSDN. For more information about setting up your own certification authority (CA), see Active Directory Certificate Services
(http://go.microsoft.com/fwlink/?linkid=136444) in the TechNet Library.
Create and use one of the following Windows PowerShell script files to deploy SharePoint Server on a single server.
simplesingleserver.ps1: Installs SharePoint Server 2010 using the built-in database to store configuration information and documents.
simplefarm.ps1: Installs SharePoint Server 2010 using either SQL Server 2005 or SQL Server 2008 to store configuration information and documents.
simplesingleserver.ps1
This script deploys SharePoint Server 2010 on a single server that uses the built-in database.
Copy the following code to a text editor and save it as simplesingleserver.ps1 in the directory of your choice:
noteDXDOC112778PADS Security Note
$SetupPath = Read-Host -Prompt "Please specify the path to the install media (D:)"
## Here is the script to install SharePoint Server 2010 with SQL Express and create Central Admin ##
& $SetupPath\PrerequisiteInstaller.exe /unattended | Write-Host if( $lastexitcode -eq 0 ) {
& $SetupPath\setup.exe /config $SetupPath\Files\SetupSilent\config.xml | Write-Host if( $lastexitcode -eq 0 ) {
Write-Host "Install successful..."
} else { Write-Error "ERROR: $lastexitcode" } } else { Write-Error "ERROR: $lastexitcode" }
1. Navigate to the Files\SetupSilent directory on the installation source and open config.xml in a text editor.
2. Locate the <!--<PIDKEY Value="Enter Product Key Here" />--> line.
3. Replace "Enter Product Key Here" with one of the following PIDKEYs: PKXTJ-DCM9D-6MM3V-G86P8-MJ8CY or BV7VC-RMR6B-26P6Y-BTQDG-DX2KQ
4. Remove the comment markers for the line of code you edited and then save the config.xml file.
5. Start Windows PowerShell 2.0 using the Run as administrator option.
6. Navigate to the directory where you saved simplesingleserver.ps1.
7. Run .\simplesingleserver.ps1 from the Windows PowerShell command prompt.
simplefarm.ps1
This script deploys SharePoint Server 2010 on a single server that uses a SQL Server database. Copy the following code to a text editor and save it as simplefarm.ps1 in the directory of your choice:
## Settings you may want to change ##
$err = $null
$SetupPath = Read-Host -Prompt "Please specify the path to the install media (D:)"
Write-Host "Please specify the Farm Administrator credentials"
$FarmCredential = Get-Credential "DOMAIN\<Farm Admin>"
$DBServer = Read-Host -Prompt "Please enter the name of your database server"
To run simplesingleserver.ps1
$Passphrase = ReadHost Prompt "Please enter the farm passphrase (optional)" -AsSecureString
$FarmName = Read-Host -Prompt "Please enter a farm name (optional)"
$CAPort = Read-Host -Prompt "Please enter the Central Administration port number (optional)"
if ([String]::IsNullOrEmpty($SetupPath)) {
Write-Error "You must enter the install media path"
return }
if ([String]::IsNullOrEmpty($FarmCredential)) {
Write-Error "You must enter a Farm Administrator's user name and password"
return }
if ([String]::IsNullOrEmpty($DBServer)) {
Write-Error "You must enter a database server"
return }
if ($Passphrase.Length -eq 0) {
Write-Warning "You didn't enter a farm passphrase, using the Farm Administrator's password instead"
$Passphrase = $FarmCredential.Password }
if ([String]::IsNullOrEmpty($FarmName)) {
Write-Warning "You didn't enter a farm name, using the machine name instead"
$FarmName = $env:COMPUTERNAME }
if ([String]::IsNullOrEmpty($CAPort)) {
Write-Warning "You didn't enter a Central Administration port number, using 5000 instead"
$CAPort = 5000
}
## Here is the script to install SharePoint Server 2010 and create Central Admin ##
Write-Host "[1/15] Running prerequisite installer..."
& $SetupPath\PrerequisiteInstaller.exe /unattended | Write-Host if( $lastexitcode -eq 0 ) {
Write-Host "[2/15] Running silent farm binary installation... (this will take some time)"
& $SetupPath\setup.exe /config $SetupPath\Files\SetupFarmSilent\config.xml | Write-Host Write-Host "[3/15] Completed silent farm binary installation."
if( $lastexitcode -eq 0 ) {
Add-PSSnapin Microsoft.SharePoint.PowerShell -erroraction SilentlyContinue Write-Host "[4/15] 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/15] Verifying farm creation..."
$spfarm = get-spfarm
if ($spfarm -ne $null) {
Write-Host "[6/15] ACLing SharePoint Resources..."
Initialize-SPResourceSecurity -ErrorVariable err if ([String]::IsNullOrEmpty($err) -eq $true) { Write-Host "[7/15] Installing Services..."
Install-SPService -ErrorVariable err
if ([String]::IsNullOrEmpty($err) -eq $true) { Write-Host "[8/15] Installing Features..."
Install-SPFeature -AllExistingFeatures -ErrorVariable err if ([String]::IsNullOrEmpty($err) -eq $true) {
Write-Host "[9/15] Provisioning Central Administration..."
NewSPCentralAdministration Port $CAPort WindowsAuthProvider "NTLM" -ErrorVariable err
if ([String]::IsNullOrEmpty($err) -eq $true) { Write-Host "[10/15] Installing Help..."
Install-SPHelpCollection -All -ErrorVariable err if ([String]::IsNullOrEmpty($err) -eq $true) {
Write-Host "[11/15] Installing Application Content..."
Install-SPApplicationContent -ErrorVariable err
if ([String]::IsNullOrEmpty($err) -eq $true) {
Write-Host "[12/15] Basic configuration completed."
$SPManagedAccount = Get-SPManagedAccount
$FarmCredential.UserName
Write-Host "[13/15] Creating Web Application and Application Pool..."
$webApp = NewSPWebApplication Name "SharePoint 80" -ApplicationPool "SharePoint - 80" --ApplicationPoolAccount $SPManagedAccount -DatabaseServer
$DBServer -DatabaseName ("{0}_Content_DB" -f $FarmName) -Url "http://localhost" -ErrorVariable err
if ([String]::IsNullOrEmpty($err) -eq $true) { Write-Host "[14/15] Creating site collection..."
$SPSite = NewSPSite url "http://localhost" -OwnerAlias $FarmCredential.UserName -ErrorVariable err
if ([String]::IsNullOrEmpty($err) -eq $true) { Write-Host "[15/15] Port 80 Web application and site collect created. Browse to http://localhost to pick a template for the Web..."
} 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" } } else { Write-Error "ERROR: $err" } } else { Write-Error "ERROR: $err" } } else { Write-Error "ERROR: $lastexitcode" } } else { Write-Error "ERROR: $lastexitcode" }
$exitprompt = Read-Host -Prompt "Press Enter to exit..."
1. Navigate to the Files\SetupFarmSilent directory on the installation source and open config.xml in a text editor.
2. Locate the <!--<PIDKEY Value="Enter Product Key Here" />--> line.
3. Replace "Enter Product Key Here" with one of the following PIDKEYs: PKXTJ-DCM9D-6MM3V-G86P8-MJ8CY or BV7VC-RMR6B-26P6Y-BTQDG-DX2KQ
To run simplefarm.ps1
4. Remove the comment markers for the line of code you edited and then save the config.xml file.
5. Start Windows PowerShell 2.0 using the Run as administrator option.
6. Navigate to the directory where you saved simplefarm.ps1.
7. Run .\simplefarm.ps1 from the Windows PowerShell command prompt.