-
Notifications
You must be signed in to change notification settings - Fork 10
Expand file tree
/
Copy pathInstallSQLDeveloperEdition.ps1
More file actions
52 lines (35 loc) · 1.67 KB
/
InstallSQLDeveloperEdition.ps1
File metadata and controls
52 lines (35 loc) · 1.67 KB
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
$isoLocation = ## Put the location here
$pathToConfigurationFile = ## Path to original file here
$copyFileLocation = "C:\Temp\ConfigurationFile.ini"
$errorOutputFile = "C:\Temp\ErrorOutput.txt"
$standardOutputFile = "C:\Temp\StandardOutput.txt"
Write-Host "Copying the ini file"
New-Item "C:\Temp" -ItemType "Directory" -Force
Remove-Item $errorOutputFile -Force
Remove-Item $standardOutputFile -Force
Copy-Item $pathToConfigurationFile $copyFileLocation -Force
Write-Host "Getting the name of the current user to replace in the copy ini file"
$user = "$env:UserDomain\$env:USERNAME"
write-host $user
Write-Host "Replacing the placeholder user name with your username"
$replaceText = (Get-Content -path $copyFileLocation -Raw) -replace "##MyUser##", $user
Set-Content $copyFileLocation $replaceText
Write-Host "Mounting SQL Server Image"
$drive = Mount-DiskImage -ImagePath $isoLocation
Write-Host "Getting Disk drive of the mounted image"
$disks = Get-WmiObject -Class Win32_logicaldisk -Filter "DriveType = '5'"
foreach ($disk in $disks){
$driveLetter = $disk.DeviceID
}
if ($driveLetter)
{
Write-Host "Starting the install of SQL Server"
Start-Process $driveLetter\Setup.exe "/ConfigurationFile=$copyFileLocation" -Wait -RedirectStandardOutput $standardOutputFile -RedirectStandardError $errorOutputFile
}
$standardOutput = Get-Content $standardOutputFile -Delimiter "\r\n"
Write-Host $standardOutput
$errorOutput = Get-Content $errorOutputFile -Delimiter "\r\n"
Write-Host $errorOutput
Write-Host "Dismounting the drive"
Dismount-DiskImage -InputObject $drive
Write-Host "If no red text then SQL Server Successfully Installed!"