Skip to content

Commit 1fa0801

Browse files
committed
Iteration 2
1 parent ec52402 commit 1fa0801

22 files changed

Lines changed: 844 additions & 104 deletions

.vscode/settings.json

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,18 @@
7373
"dbatools",
7474
"db_datareader",
7575
"fastbuild",
76-
"SSMS"
76+
"SSMS",
77+
"HKEY",
78+
"POWERPIVOT",
79+
"Tempdb",
80+
"NPENABLED",
81+
"TCPENABLED",
82+
"RSINSTALLMODE",
83+
"SVCACCOUNT",
84+
"SVCPASSWORD",
85+
"SQLSERVERAGENT",
86+
"MSSQLFD",
87+
"MSRS"
7788
],
7889
"cSpell.ignorePaths": [
7990
".git"
Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
<#
2+
.SYNOPSIS
3+
Common properties across all components that can be installed.
4+
5+
.EXAMPLE
6+
[InstalledComponentSetting]::new()
7+
8+
Creates a new empty object.
9+
10+
.NOTES
11+
This class should be parent of an derived class that have more properties
12+
that are unique for each component.
13+
#>
14+
class InstalledComponentSetting
15+
{
16+
[System.String[]]
17+
$FeatureList
18+
19+
[System.Version]
20+
$Version
21+
22+
[System.Version]
23+
$PatchLevel
24+
25+
[System.String]
26+
$Edition
27+
28+
[System.String]
29+
$EditionType
30+
31+
[Nullable[System.UInt32]]
32+
$Language
33+
34+
[System.String]
35+
$ProductCode
36+
37+
[System.String]
38+
$SqlPath
39+
40+
InstalledComponentSetting ()
41+
{
42+
}
43+
44+
static [InstalledComponentSetting] op_Addition([InstalledComponentSetting] $Left, [InstalledComponentSetting] $Right)
45+
{
46+
$propertyList = $Left.PSObject.Properties.Name
47+
48+
foreach ($property in $propertyList)
49+
{
50+
# Only add values if left side is $null and right side is not null.
51+
if (-not $Left.$property -and $Right.$property)
52+
{
53+
$Left.$property = $Right.$property
54+
}
55+
}
56+
57+
return $Left
58+
}
59+
60+
static [InstalledComponentSetting] Parse([PSCustomObject] $Settings)
61+
{
62+
$installedComponentSetting = [InstalledComponentSetting]::new()
63+
64+
if ($settings.FeatureList)
65+
{
66+
$installedComponentSetting.FeatureList = $settings.FeatureList -split ' '
67+
}
68+
69+
$propertyList = (
70+
$installedComponentSetting.PSObject.Properties |
71+
Where-Object -FilterScript {
72+
$_.Name -ne 'FeatureList'
73+
}
74+
).Name
75+
76+
foreach ($property in $propertyList)
77+
{
78+
if ($settings.$property)
79+
{
80+
$installedComponentSetting.$property = $settings.$property
81+
}
82+
}
83+
84+
return $installedComponentSetting
85+
}
86+
}
Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
<#
2+
.SYNOPSIS
3+
Returns the integration services settings.
4+
5+
.DESCRIPTION
6+
Returns the integration services settings.
7+
8+
.PARAMETER Version
9+
Specifies the version for which to return settings for.
10+
11+
.OUTPUTS
12+
`[System.Management.Automation.PSCustomObject]`
13+
14+
.EXAMPLE
15+
Get-SqlDscIntegrationServicesSetting -Version ([System.Version] '16.0')
16+
17+
Returns the settings for the integration services.
18+
#>
19+
function Get-SqlDscDatabaseEngineSetting
20+
{
21+
[CmdletBinding()]
22+
[OutputType([System.Boolean])]
23+
param
24+
(
25+
[Parameter(Mandatory = $true)]
26+
[System.Version]
27+
$Version
28+
)
29+
30+
<#
31+
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Microsoft SQL Server\MSSQL13.SQL2016\Setup
32+
33+
FeatureList
34+
Version
35+
PatchLevel
36+
Edition
37+
EditionType
38+
Language
39+
ProductCode
40+
SqlPath
41+
42+
TODO: Gör en Get-SqlDscServiceName med data från HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Microsoft SQL Server\Services
43+
Liknande Get-SqlDscInstalledInstance
44+
#>
45+
$masterDataServicesSettings = $null
46+
47+
$getItemPropertyParameters = @{
48+
Path = 'HKLM:\SOFTWARE\Microsoft\Microsoft SQL Server\{0}0\Master Data Services\Setup\MDSCoreFeature' -f $Version.Major
49+
ErrorAction = 'SilentlyContinue'
50+
}
51+
52+
$mdsCoreFeatureSettings = Get-ItemProperty @getItemPropertyParameters
53+
54+
if (-not $mdsCoreFeatureSettings)
55+
{
56+
$missingIntegrationServiceMessage = $script:localizedData.MasterDataServicesSetting_Get_NotInstalled -f $Version.ToString()
57+
58+
$writeErrorParameters = @{
59+
Message = $missingIntegrationServiceMessage
60+
Category = 'InvalidOperation'
61+
ErrorId = 'GISS0001' # cspell: disable-line
62+
TargetObject = $Version
63+
}
64+
65+
Write-Error @writeErrorParameters
66+
}
67+
else
68+
{
69+
$masterDataServicesSettings1 = [InstalledComponentSetting]::Parse($mdsCoreFeatureSettings)
70+
71+
$getItemPropertyParameters = @{
72+
Path = 'HKLM:\SOFTWARE\Microsoft\Microsoft SQL Server\{0}0\Master Data Services\Setup' -f $Version.Major
73+
ErrorAction = 'SilentlyContinue'
74+
}
75+
76+
$mdsSetupSettings = Get-ItemProperty @getItemPropertyParameters
77+
78+
$masterDataServicesSettings2 = [InstalledComponentSetting]::Parse($mdsSetupSettings)
79+
80+
$masterDataServicesSettings = $masterDataServicesSettings1 + $masterDataServicesSettings2
81+
}
82+
83+
return $masterDataServicesSettings
84+
}

0 commit comments

Comments
 (0)