-
Notifications
You must be signed in to change notification settings - Fork 1
/
Join-Farm.ps1
79 lines (67 loc) · 2.54 KB
/
Join-Farm.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
<#
.SYNOPSIS
Joins a machine to a SharePoint Farm.
.DESCRIPTION
25/06/2015
12/01/2016: updates for 2013 farm support
.NOTES
File Name : Join-Farm.ps1
Author : Spencer Harbar ([email protected])
Requires : PowerShell Version 2.0
.LINK
.PARAMETER File
The configuration file
#>
#region PARAMS
param (
[String]$Server,
[String]$DatabaseServer,
[String]$ConfigDatabase,
[SecureString]$Passphrase,
[String]$ServerRole,
[bool]$ServerRoleOptional
)
#endregion PARAMS
#region MAIN
try {
If ((Get-PSSnapin -Name "Microsoft.SharePoint.PowerShell" -EA 0) -eq $null) { Add-PSSnapin -Name "Microsoft.SharePoint.PowerShell" }
Write-Output "$(Get-Date -Format T) : Joining server $Server to the farm as $ServerRole..."
if ($ServerRoleOptional) {
Connect-SPConfigurationDatabase -DatabaseName $ConfigDatabase `
-DatabaseServer $DatabaseServer `
-Passphrase $Passphrase `
-SkipRegisterAsDistributedCacheHost
}
else {
Connect-SPConfigurationDatabase -DatabaseName $ConfigDatabase `
-DatabaseServer $DatabaseServer `
-Passphrase $Passphrase `
-LocalServerRole $ServerRole `
-SkipRegisterAsDistributedCacheHost
}
Write-Output "$(Get-Date -Format T) : Installing Help..."
Install-SPHelpCollection -All
Write-Output "$(Get-Date -Format T) : ACLing SharePoint Resources..."
Initialize-SPResourceSecurity
Write-Output "$(Get-Date -Format T) : Installing Services..."
Install-SPService | Out-Null
Write-Output "$(Get-Date -Format T) : Installing Features..."
Install-SPFeature -AllExistingFeatures | Out-Null
# if role is Search then don't install app content as the Content Service isn't present
if ($ServerRole -ne "Search") {
Write-Output "$(Get-Date -Format T) : Installing Application Content..."
Install-SPApplicationContent
}
Write-Output "$(Get-Date -Format T) : Server $Server joined to the farm!"
Write-Output "$(Get-Date -Format T) : Restarting SharePoint Timer Service..."
Restart-Service -Name "SPTimerV4"
Write-Output "$(Get-Date -Format T) : SharePoint Timer Service Restarted!"
}
catch {
Write-Host "OOOPS! We failed during Farm Join on $server." -ForegroundColor Red
$_
Exit
}
#endregion MAIN
#EOF