-
Notifications
You must be signed in to change notification settings - Fork 1
/
Install-SQLServer.ps1
46 lines (40 loc) · 2.88 KB
/
Install-SQLServer.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
Param ($instancename,$Role,$InstanceOwner,$SQLAdminGroup)
Import-Module NetSecurity
If ($InstanceName -eq "Default")
{
$Datapath = "R:\MSSQL"
$LogPath = "T:\MSSQL"
$BackupPath = "S:\SQL_Backup"
$InstanceName = "MSSQLServer"
$Features = "SQL,RS"
}
Else
{
$Datapath = "R:\$InstanceName"
$LogPath = "T:\$InstanceName"
$BackupPath = "S:\SQL_Backup"
$Features = "SQL,RS"
}
$Domain = $env:USERDOMAIN
$AdminGroup = "$Domain\$SQLAdminGroup"
switch ($role)
{
("DB"){
If ($InstanceOwner -ne $null)
{
E:\SQLInstall\2012\Setup.exe /ACTION= "Install" /IAcceptSQLServerLicenseTerms /Q /FEATURES= $Features /INSTALLSHAREDDIR= "E:\Program Files\Microsoft SQL Server" /INSTANCEDIR= "E:\Program Files\Microsoft SQL Server" /INSTALLSQLDATADIR= "E:\Program Files\Microsoft SQL Server" /INSTALLSHAREDWOWDIR= "E:\Program Files (x86)\Microsoft SQL Server" /INSTANCENAME= "$Instancename" /INSTANCEID= $instancename /SQMREPORTING= 0 /RSINSTALLMODE= FilesOnlyMode /ERRORREPORTING= 0 /AGTSVCSTARTUPTYPE= "Automatic" /SQLSVCSTARTUPTYPE= "Automatic" /SQLCOLLATION= "SQL_Latin1_General_CP1_CI_AS" /SQLSYSADMINACCOUNTS= "$AdminGroup" "$Domain\$InstanceOwner" /SQLBACKUPDIR= "$BackupPath" /SQLUSERDBDIR= "$DataPath" /SQLUSERDBLOGDIR= "$LogPath" /SQLTEMPDBDIR= "R:\TempDB\$InstanceName" /SQLTEMPDBLOGDIR= "T:\TempDB\$InstanceName" /TCPENABLED= "1"
}
Else
{
E:\SQLInstall\2012\Setup.exe /ACTION= "Install" /IAcceptSQLServerLicenseTerms /Q /FEATURES= $Features /INSTALLSHAREDDIR= "E:\Program Files\Microsoft SQL Server" /INSTANCEDIR= "E:\Program Files\Microsoft SQL Server" /INSTALLSQLDATADIR= "E:\Program Files\Microsoft SQL Server" /INSTALLSHAREDWOWDIR= "E:\Program Files (x86)\Microsoft SQL Server" /INSTANCENAME= "$Instancename" /INSTANCEID= $instancename /SQMREPORTING= 0 /RSINSTALLMODE= FilesOnlyMode /ERRORREPORTING= 0 /AGTSVCSTARTUPTYPE= "Automatic" /SQLSVCSTARTUPTYPE= "Automatic" /SQLCOLLATION= "SQL_Latin1_General_CP1_CI_AS" /SQLSYSADMINACCOUNTS= "$AdminGroup" /SQLBACKUPDIR= "$BackupPath" /SQLUSERDBDIR= "$DataPath" /SQLUSERDBLOGDIR= "$LogPath" /SQLTEMPDBDIR= "R:\TempDB\$InstanceName" /SQLTEMPDBLOGDIR= "T:\TempDB\$InstanceName" /TCPENABLED= "1"
}
Set-Location -Path C:\
$ProgramPath = "E:\Program Files\Microsoft SQL Server\MSSQL11.$instanceName\MSSQL\Binn\sqlservr.exe"
$pathexists = Test-Path -Path $ProgramPath
If ($pathExists -eq $true)
{
New-NetFirewallRule -Program $ProgramPath -DisplayName "SQL Server - $instancename" -Direction Inbound -Action Allow -Profile Domain
}
}
("Base") { E:\SQLInstall\2012\Setup.exe /ACTION= "Install" /IAcceptSQLServerLicenseTerms /Q /FEATURES= BIDS, CONN, SSMS, ADV_SSMS /INSTALLSHAREDDIR= "E:\Program Files\Microsoft SQL Server" /INSTANCEDIR= "E:\Program Files\Microsoft SQL Server" /INSTALLSQLDATADIR= "E:\Program Files\Microsoft SQL Server" /INSTALLSHAREDWOWDIR= "E:\Program Files (x86)\Microsoft SQL Server" /SQMREPORTING= 0 /ERRORREPORTING= 0 }
}