1
-
2
-
3
-
4
- Function Install-ADAuthenticationLibraryforSQLServer {
5
- # from https://bzzzt.io/post/2018-05-25-horrible-adalsql-issue/
6
- $workingFolder = Join-Path $Env: TEMP ([System.IO.Path ]::GetRandomFileName())
7
- New-Item - ItemType Directory - Force - Path $workingFolder
8
-
9
- $Installer = ' C:\github\appveyor-lab\azure\adalsql.msi'
10
-
11
- If (! (Test-Path $Installer )) {
12
- Throw " $Installer does not exist"
13
- }
14
- try {
15
- # Write-Host "attempting to uninstall..."
16
- # Write-Host "Running MsiExec.exe /uninstall {4EE99065-01C6-49DD-9EC6-E08AA5B13491} /quiet"
17
- Start-Process - FilePath " MsiExec.exe" - ArgumentList " /uninstall {4EE99065-01C6-49DD-9EC6-E08AA5B13491} /quiet" - Wait - NoNewWindow
18
- } catch {
19
- # Write-Host "oh dear install did not work"
20
- $fail = $_.Exception
21
- Write-Error $fail
22
- Throw
23
- }
24
- try {
25
- $DataStamp = get-date - Format yyyyMMddTHHmmss
26
- $logFile = ' {0}-{1}.log' -f $Installer , $DataStamp
27
- $MSIArguments = @ (
28
- " /i"
29
- (' "{0}"' -f $Installer )
30
- " /qn"
31
- " /norestart"
32
- " /L*v"
33
- $logFile
34
- )
35
- # Write-Host "Attempting to install.."
36
- # Write-Host " Running msiexec.exe $($MSIArguments)"
37
- Start-Process " msiexec.exe" - ArgumentList $MSIArguments - Wait - NoNewWindow
38
- } catch {
39
- $fail = $_.Exception
40
- Write-Error $fail
41
- Throw
42
- }
43
- }
44
-
45
- $null = Install-ADAuthenticationLibraryforSQLServer
46
-
47
1
$indent = ' ...'
48
2
Write-Host - Object " $indent Running $PSCommandpath " - ForegroundColor DarkGreen
49
- Import-Module C:\github\dbatools\dbatools.psm1 - Force
50
- $null = Set-DbatoolsInsecureConnection
51
3
52
4
# This script spins up the 2008R2SP2 instance and the relative setup
53
5
@@ -56,46 +8,20 @@ $instance = "SQL2008R2SP2"
56
8
$port = " 1433"
57
9
58
10
Write-Host - Object " $indent Setting up AppVeyor Services" - ForegroundColor DarkGreen
59
- Set-Service - Name SQLBrowser - StartupType Automatic - WarningAction SilentlyContinue
60
- Start-Service SQLBrowser - ErrorAction SilentlyContinue - WarningAction SilentlyContinue
11
+ Set-Service - Name SQLBrowser - StartupType Automatic
12
+ Start-Service - Name SQLBrowser
61
13
62
14
63
15
Write-Host - Object " $indent Changing the port on $instance to $port " - ForegroundColor DarkGreen
64
- $wmi = New-Object Microsoft.SqlServer.Management.Smo.Wmi.ManagedComputer
65
- $uri = " ManagedComputer[@Name='$env: COMPUTERNAME ']/ServerInstance[@Name='$instance ']/ServerProtocol[@Name='Tcp']"
66
- $Tcp = $wmi.GetSmoObject ($uri )
67
- foreach ($ipAddress in $Tcp.IPAddresses ) {
68
- $ipAddress.IPAddressProperties [" TcpDynamicPorts" ].Value = " "
69
- $ipAddress.IPAddressProperties [" TcpPort" ].Value = $port
70
- }
71
- $Tcp.Alter ()
72
-
73
- $uri = " ManagedComputer[@Name='$env: COMPUTERNAME ']/ServerInstance[@Name='$instance ']/ServerProtocol[@Name='Np']"
74
- $Np = $wmi.GetSmoObject ($uri )
75
- $Np.IsEnabled = $true
76
- $Np.Alter ()
16
+ $null = Set-DbaNetworkConfiguration - SqlInstance $sqlinstance - StaticPortForIPAll $port - EnableException - Confirm:$false - WarningAction SilentlyContinue
77
17
78
- Write-Host - Object " $indent Starting $instance " - ForegroundColor DarkGreen
79
- Restart-Service " MSSQL`$ $instance " - WarningAction SilentlyContinue - Force
80
- $server = Connect-DbaInstance - SqlInstance $sqlinstance
81
- $server.Configuration.RemoteDacConnectionsEnabled.ConfigValue = $true
82
- $server.Configuration.Alter ()
83
- $null = Set-DbaStartupParameter - SqlInstance $sqlinstance - TraceFlagOverride - TraceFlag 7806 - Confirm:$false - ErrorAction SilentlyContinue - EnableException
84
- Restart-Service " MSSQL`$ SQL2008R2SP2" - WarningAction SilentlyContinue - Force
85
- $server = Connect-DbaInstance - SqlInstance $sqlinstance
86
- $server.Configuration.RemoteDacConnectionsEnabled.ConfigValue = $true
87
- $server.Configuration.Alter ()
18
+ Restart-Service - Name " MSSQL`$ SQL2008R2SP2" - Force
88
19
89
- do {
90
- Start-Sleep 1
91
- $null = (& sqlcmd - S " $sqlinstance " - b - Q " select 1" - d master)
92
- }
93
- while ($lastexitcode -ne 0 -and $t ++ -lt 10 )
94
20
95
- Write-Host - Object " $indent Executing startup scripts for SQL Server 2008" - ForegroundColor DarkGreen
96
- # Add some jobs to the sql2008r2sp2 instance (1433 = default)
97
- foreach ($file in (Get-ChildItem C:\github\appveyor- lab\sql2008- startup\* .sql - Recurse - ErrorAction SilentlyContinue)) {
98
- Invoke-DbaQuery - SqlInstance $sqlinstance - InputFile $file
99
- }
21
+ Write-Host - Object " $indent Configuring $sqlinstance " - ForegroundColor DarkGreen
100
22
101
- Import-Module C:\github\dbatools\dbatools.psm1 - Force
23
+ $null = Set-DbaNetworkConfiguration - SqlInstance $sqlinstance - EnableProtocol NamedPipes - RestartService - EnableException - Confirm:$false
24
+ $null = Set-DbaSpConfigure - SqlInstance $sqlinstance - Name RemoteDacConnectionsEnabled - Value $true - EnableException
25
+ # To conserve resources, SQL Server Express doesn't listen on the DAC port unless started with a trace flag 7806.
26
+ $null = Set-DbaStartupParameter - SqlInstance $sqlinstance - TraceFlagOverride - TraceFlag 7806 - EnableException - Confirm:$false
27
+ Restart-Service - Name " MSSQL`$ SQL2008R2SP2" - Force
0 commit comments