Skip to content

Commit 425fb24

Browse files
Fix SSIS Connection Logic (#9743)
1 parent 19a5114 commit 425fb24

File tree

3 files changed

+42
-8
lines changed

3 files changed

+42
-8
lines changed

public/Get-DbaSsisEnvironmentVariable.ps1

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -133,10 +133,7 @@ function Get-DbaSsisEnvironmentVariable {
133133
}
134134

135135
try {
136-
$legacyconnstring = $server | New-DbaConnectionString -Legacy
137-
$sqlconnection = New-Object System.Data.SqlClient.SqlConnection $legacyconnstring
138-
$null = $sqlconnection.Open()
139-
$ssis = New-Object Microsoft.SqlServer.Management.IntegrationServices.IntegrationServices $sqlconnection
136+
$ssis = New-Object Microsoft.SqlServer.Management.IntegrationServices.IntegrationServices $server
140137
} catch {
141138
Stop-Function -Message "Can't load server" -Target $instance -ErrorRecord $_
142139
return

public/New-DbaSsisCatalog.ps1

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -128,10 +128,7 @@ function New-DbaSsisCatalog {
128128
}
129129

130130
try {
131-
$legacyconnstring = $server | New-DbaConnectionString -Legacy
132-
$sqlconnection = New-Object System.Data.SqlClient.SqlConnection $legacyconnstring
133-
$null = $sqlconnection.Open()
134-
$ssis = New-Object Microsoft.SqlServer.Management.IntegrationServices.IntegrationServices $sqlconnection
131+
$ssis = New-Object Microsoft.SqlServer.Management.IntegrationServices.IntegrationServices $server
135132
} catch {
136133
Stop-Function -Message "Can't load server" -Target $instance -ErrorRecord $_
137134
return

tests/Get-DbaSsisEnvironmentVariable.Tests.ps1

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,46 @@ Describe "$CommandName Unit Tests" -Tag 'UnitTests' {
1212
}
1313
}
1414
}
15+
16+
<#
17+
18+
-- Create a folder if it doesn't exist
19+
IF NOT EXISTS (SELECT 1 FROM [SSISDB].[catalog].[folders] WHERE name = N'TestFolder')
20+
BEGIN
21+
EXEC [SSISDB].[catalog].[create_folder] @folder_name = N'TestFolder', @folder_id = NULL;
22+
END
23+
24+
-- Create an environment in the folder if it doesn't exist
25+
IF NOT EXISTS (
26+
SELECT 1 FROM [SSISDB].[catalog].[environments]
27+
WHERE name = N'TestEnv' AND folder_id = (SELECT folder_id FROM [SSISDB].[catalog].[folders] WHERE name = N'TestFolder')
28+
)
29+
BEGIN
30+
EXEC [SSISDB].[catalog].[create_environment] @folder_name = N'TestFolder', @environment_name = N'TestEnv';
31+
END
32+
33+
-- Create an environment variable in the environment if it doesn't exist
34+
IF NOT EXISTS (
35+
SELECT 1 FROM [SSISDB].[catalog].[environment_variables]
36+
WHERE name = N'TestVar'
37+
AND environment_id = (
38+
SELECT environment_id
39+
FROM [SSISDB].[catalog].[environments]
40+
WHERE name = N'TestEnv'
41+
AND folder_id = (SELECT folder_id FROM [SSISDB].[catalog].[folders] WHERE name = N'TestFolder')
42+
)
43+
)
44+
BEGIN
45+
EXEC [SSISDB].[catalog].[create_environment_variable]
46+
@folder_name = N'TestFolder',
47+
@environment_name = N'TestEnv',
48+
@variable_name = N'TestVar',
49+
@data_type = N'String',
50+
@sensitive = 0,
51+
@value = N'Chello';
52+
END
53+
54+
#>
1555
<#
1656
Integration test should appear below and are custom to the command you are writing.
1757
Read https://github.com/sqlcollaborative/dbatools/blob/development/contributing.md#tests

0 commit comments

Comments
 (0)