-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathExecute-Scripts.ps1
More file actions
43 lines (36 loc) · 964 Bytes
/
Execute-Scripts.ps1
File metadata and controls
43 lines (36 loc) · 964 Bytes
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
## Install-Module -Name SqlServer
param(
[Parameter(Mandatory=$false)]
[string]
$Server = "localhost"
)
$connectionString = "server=$Server;uid=sa;pwd=P@ssw0rd;Initial Catalog=master;Connect Timeout=3;"
function Test-SqlConnection{
$sqlConnection = New-Object System.Data.SqlClient.SqlConnection
$sqlConnection.ConnectionString = $connectionString
$isSuccess = $false
try
{
$sqlConnection.Open()
if ($sqlConnection.State -eq 'Open')
{
$isSuccess = $true
}
}
catch {
$isSuccess = $false
}
finally {
$sqlConnection.Close();
}
return $isSuccess
}
$isLive = $false
while(!$isLive) {
$isLive = Test-SqlConnection -server $Server
Start-Sleep -Milliseconds 200
Write-Progress -Activity "Waiting for database"
}
Write-Progress "Creating Schema"
Invoke-Sqlcmd -ConnectionString $connectionString -InputFile "$PSScriptRoot/schema.sql"
Write-Progress "Completed"