1. Join a Server to the SharePoint Farm
Scenario/Problem: You need to join the servers to the new SharePoint farm.
Solution: Use the Join-SharePointFarm
cmdlet from the SPModule
.
The previous cmdlet (New-SharePointFarm
)
created the database and configured the SharePoint farm. You cannot run
this again on the other servers. Instead, you need to join the servers
to the farm using the Join-SharePointFarm
cmdlet:
Join-SharePointFarm -databaseserver <database server name>
-configurationdatabasename <config database>
-passphrase (ConvertTo-SecureString -asplaintext -force -string
"<farm pass phrase>")
The farm passphrase used with the Join-SharePointFarm
cmdlet should be the same passphrase used when you are creating the new SharePoint farm.
2. Create a New Web Application
Scenario/Problem: You need to create a new web application for the SharePoint farm.
Solution: Use the New-SPWebApplication
cmdlet from the SharePoint 2013 Management Shell.
You can now use the SharePoint 2013 Management Shell because SharePoint has been installed and the SPModule
commands have been utilized. If you are running a full script and/or
still want to use the PowerShell console, be sure to add the SharePoint
snap-in (Add-PsSnapin Microsoft.SharePoint.PowerShell
) so that the SharePoint cmdlets are available.
To add a new web application, use the New-SPWebApplication
cmdlet as follows:
New-SPWebApplication -applicationpool <name of new application pool>
-name <name of new web app>
-applicationpoolaccount <service account to be used for the
application pool> -port <desired port number>
Listing 1 shows a sample command-line entry for creating the main SharePoint web application.
Listing 1. Creating a New Web Application
New-SPWebApplication -applicationpool SharePoint-80
-name SharePoint-80 -applicationpoolaccount SP\AppPoolAccount -port 80
This process might take a few minutes. When
it completes, the console presents the display name and the URL of the
new web application.
Tip
If you do not include the port number, a
random port number will be assigned. The first web application created
will use port 80.
3. Create a New Site Collection
Scenario/Problem: You need to create a new top-level site collection.
Solution: Use the New-SPSite
cmdlet from the SharePoint 2013 Management Shell.
To add a new site collection, use the New-SPSite
cmdlet as follows:
New-SPSite -url <full url of new site collection>
-name <name of new site collection>
-owneralias <site collection administrator>
-template <site collection template to use>
Listing 2 shows a sample command-line entry for creating the root site collection using the Team Site template.
Listing 2. Creating the Root Top-Level Site Collection
New-SPSite -url http://sp2013/ -name Home -owneralias SP\SiteAdmin
-template STS#0
You can find the site template names using Get-SPWebTemplate
.
If no template is provided, the site collection is still created. In
this case, after the site is accessed via the browser, SharePoint
prompts for the selection of a site collection template.