Created
April 30, 2014 13:52
-
-
Save robie2011/0a21ecb52561d196d5fe to your computer and use it in GitHub Desktop.
Powershell Installation Scripts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<# | |
.SYNOPSIS | |
Install SQL2008R2 Server | |
.DESCRIPTION | |
use Switches to install SQL Server Features easy and silently | |
.PARAMETER instanceName | |
Name of SQL Instance | |
.PARAMETER useGerman | |
Install German Version of SQL Server (Managementstudio) | |
.PARAMETER installOnly | |
Use this parameter to only install Managementstudio or SQL Engine | |
.EXAMPLE | |
Install-SQL2008R2.ps1 -installOnly SQLEngine -useGerman | |
.Notes | |
File Name : Install-SQL2008R2.ps1 | |
Author : Robert Rajakone | |
Date : 05. September 2013 | |
#> | |
param( | |
[string] $instanceName="SQL2008R2", | |
[switch] $useGermanVersion, | |
[ValidateSet('SQLEngine', 'ManagementStudio')] | |
[string] $installOnly | |
) | |
#Changing to germany regional settings | |
if($useGermanVersion){ Start-Process -Wait -ArgumentList @("/c", "\\DOS-Scripts\change_locale_de-DE.bat") -FilePath cmd.exe } | |
#Switching Installer depending on Language | |
$Installer = "\\software\SQL Server Express Edition 2008R2\SQLEXPRADV_x64_ENU\setup.exe" | |
if($useGermanVersion){ $Installer = "\\software\SQL Server Express Edition 2008R2\SQLEXPRADV_x64_DEU.exe" } | |
# Gathering Features | |
$Features = @() | |
if($installOnly){ | |
if($installOnly.equals("SQLEngine") ){ | |
$Features +="SQLEngine" | |
$Features +="FullText" | |
} | |
if($installOnly.equals("ManagementStudio") ){ | |
$Features +="SSMS" | |
} | |
}else{ | |
$Features +="SSMS" | |
$Features +="RS" | |
$Features +="SQLEngine" | |
$Features +="FullText" | |
} | |
$FeatureList = $Features -join "," | |
$Args = @( | |
"/ACTION=Install" | |
"/IACCEPTSQLSERVERLICENSETERMS" | |
"/ERRORREPORTING=0" | |
"/FEATURES=$FeatureList" | |
"/INSTANCENAME=$instanceName" | |
"/QS" | |
"/SAPWD=secret-sa-password" | |
"/SECURITYMODE=SQL" | |
"/ADDCURRENTUSERASSQLADMIN" | |
"/RSINSTALLMODE=`"FilesOnlyMode`"" | |
) | |
#Check for Drive D | |
if(gwmi win32_volume -Filter "DriveType=3 AND DriveLetter='D:'"){ | |
Write-Host "D-Drive found. Installing on D" | |
$Args +="/INSTANCEDIR=`"D:\Programme\SQL2008R2\INSTANCE_SQL2008R2`"" | |
} | |
#Do Installing | |
Write-Host "Using the folling Parameter for installing ..." | |
$Args | %{ Write-Host $_ } | |
Start-Process -Wait -FilePath $Installer -ArgumentList $Args | |
#Changing back to swiss regional settings | |
if($useGermanVersion){ Start-Process -Wait -ArgumentList @("/c", "\\DOS-Scripts\change_locale_de-CH.bat") -FilePath cmd.exe } | |
Write-Host "Installation finish!" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment