@@ -46,67 +46,7 @@ function Get-SqlDscInstalledComponent
4646
4747 Assert-ElevatedUser - ErrorAction ' Stop'
4848
49- $serviceComponent = @ ()
50-
51- $currentInstalledServices = Get-SqlDscManagedComputerService - ServerName $ServerName - ErrorAction ' Stop'
52-
53- foreach ($installedService in $currentInstalledServices )
54- {
55- $serviceType = $installedService.Type | ConvertFrom-ManagedServiceType - ErrorAction ' SilentlyContinue'
56-
57- if (-not $serviceType )
58- {
59- <#
60- This is a workaround because [Microsoft.SqlServer.Management.Smo.Wmi.ManagedServiceType]
61- does not support all service types yet.
62- #>
63- $serviceType = $installedService.Type
64- }
65-
66- $fileProductVersion = $null
67-
68- $serviceExecutablePath = (($installedService.PathName -replace ' "' ) -split ' -' )[0 ]
69-
70- if ((Test-Path - Path $serviceExecutablePath ))
71- {
72- $fileProductVersion = [System.Version ] (Get-FileVersionInformation - FilePath $serviceExecutablePath ).ProductVersion
73- }
74-
75- # Get InstanceName from the service name if it exist.
76- $serviceInstanceName = if ($installedService.Name -match ' \$(.*)$' )
77- {
78- $Matches [1 ]
79- }
80-
81- $serviceStartMode = $installedService.StartMode | ConvertFrom-ServiceStartMode
82-
83- <#
84- There are more properties that can be fetch from advanced properties,
85- for example InstanceId, Clustered, and Version (for some), but it takes
86- about 6 seconds for it to return a value. Because of the slowness this
87- command does not use advanced properties, e.g:
88- ($installedService.AdvancedProperties | ? Name -eq 'InstanceId').Value
89- #>
90- $serviceComponent += [PSCustomObject ] @ {
91- ServiceName = $installedService.Name
92- ServiceType = $serviceType
93- ServiceDisplayName = $installedService.DisplayName
94- ServiceAccountName = $installedService.ServiceAccount
95- ServiceStartMode = $serviceStartMode
96- InstanceName = $serviceInstanceName
97- ServiceExecutableVersion = $fileProductVersion
98-
99- # Properties that should be on all objects, but set later
100- InstanceId = $null
101- Feature = @ ()
102- }
103- }
104-
105- # Get InstanceId for all installed services.
106- foreach ($component in $serviceComponent.Where ({ $_.ServiceType -in (' DatabaseEngine' , ' AnalysisServices' , ' ReportingServices' ) }))
107- {
108- $component.InstanceId = $component.ServiceType | Get-InstanceId - InstanceName $component.InstanceName
109- }
49+ $serviceComponent = Get-SqlDscInstalledService - ServerName $ServerName
11050
11151 $installedComponents = @ ()
11252
@@ -174,35 +114,31 @@ function Get-SqlDscInstalledComponent
174114 {
175115 $installedComponent |
176116 Add-Member - MemberType ' NoteProperty' - Name ' InstanceName' - Value $currentServiceComponent.InstanceName - PassThru |
177- Add-Member - MemberType ' NoteProperty' - Name ' InstanceId' - Value $currentServiceComponent.InstanceId - PassThru |
178117 Add-Member - MemberType ' NoteProperty' - Name ' Version' - Value $currentServiceComponent.ServiceExecutableVersion - PassThru |
179118 Add-Member - MemberType ' NoteProperty' - Name ' ServiceProperties' - Value $currentServiceComponent
180119
120+ # Get InstanceId for all installed services.
121+ if ($currentServiceComponent.ServiceType -in (' DatabaseEngine' , ' AnalysisServices' , ' ReportingServices' ))
122+ {
123+ $installedComponent |
124+ Add-Member - MemberType ' NoteProperty' - Name ' InstanceId' - Value (
125+ $currentServiceComponent.ServiceType |
126+ Get-InstanceId - InstanceName $currentServiceComponent.InstanceName
127+ )
128+ }
129+
181130 $installedComponents += $installedComponent
182131 }
183132 }
184133
185- # $isReplicationInstalled = Test-IsReplicationFeatureInstalled -InstanceName $InstanceName
186-
187- if ($isReplicationInstalled )
188- {
189- $component.Feature = ' Replication'
190- }
191-
192- # $isDQInstalled = Test-IsDQComponentInstalled -InstanceName $InstanceName -SqlServerMajorVersion $sqlVersion
193-
194- if ($isDQInstalled )
195- {
196- $component.Feature = ' DQ'
197- }
198-
199134 # Fetch registry keys that is three digits, like 100, 110, .., 160, and so on.
200135 $installedDatabaseLevel = (Split-Path - Leaf - Path (Get-ChildItem ' HKLM:\SOFTWARE\Microsoft\Microsoft SQL Server\' ).Name) -match ' ^\d\d\d$'
201136
202137 foreach ($databaseLevel in $installedDatabaseLevel )
203138 {
204139 $databaseLevelVersion = [System.Version ] (' {0}.{1}' -f $databaseLevel.Substring (0 , 2 ), $databaseLevel.Substring (2 , 1 ))
205140
141+ # Look for installed version of Data Quality Client.
206142 $isDQInstalled = Test-IsDataQualityClientInstalled - Version $databaseLevelVersion
207143
208144 if ($isDQInstalled )
@@ -212,22 +148,123 @@ function Get-SqlDscInstalledComponent
212148 Version = $databaseLevelVersion
213149 }
214150 }
215- }
216151
217- # $isSsmsInstalled = Test-IsSsmsInstalled -SqlServerMajorVersion $sqlVersion
152+ # Look for installed version of SQL Server Books Online.
153+ $isBOLInstalled = Test-IsBooksOnlineInstalled - Version $databaseLevelVersion
218154
219- if ($isSsmsInstalled )
220- {
221- $component.Feature = ' SSMS'
155+ if ($isBOLInstalled )
156+ {
157+ $installedComponents += [PSCustomObject ] @ {
158+ Feature = ' BOL'
159+ Version = $databaseLevelVersion
160+ }
161+ }
162+
163+ # Look for installed version of Connectivity Components.
164+ $isConnInstalled = Test-IsConnectivityComponentsInstalled - Version $databaseLevelVersion
165+
166+ if ($isConnInstalled )
167+ {
168+ $installedComponents += [PSCustomObject ] @ {
169+ Feature = ' CONN'
170+ Version = $databaseLevelVersion
171+ }
172+ }
173+
174+ # Look for installed version of Backward Compatibility Components.
175+ $isBCInstalled = Test-IsBackwardCompatibilityComponentsInstalled - Version $databaseLevelVersion
176+
177+ if ($isBCInstalled )
178+ {
179+ $installedComponents += [PSCustomObject ] @ {
180+ Feature = ' BC'
181+ Version = $databaseLevelVersion
182+ }
183+ }
184+
185+ # Look for installed version of Software Development Kit.
186+ $isSDKInstalled = Test-IsSoftwareDevelopmentKitInstalled - Version $databaseLevelVersion
187+
188+ if ($isSDKInstalled )
189+ {
190+ $installedComponents += [PSCustomObject ] @ {
191+ Feature = ' SDK'
192+ Version = $databaseLevelVersion
193+ }
194+ }
195+
196+ # Look for installed version of Master Data Services.
197+ $isMDSInstalled = Test-IsMasterDataServicesInstalled - Version $databaseLevelVersion
198+
199+ if ($isMDSInstalled )
200+ {
201+ $installedComponents += [PSCustomObject ] @ {
202+ Feature = ' MDS'
203+ Version = $databaseLevelVersion
204+ }
205+ }
222206 }
223207
224- # $isSsmsAdvancedInstalled = Test-IsSsmsAdvancedInstalled -SqlServerMajorVersion $sqlVersion
208+ $databaseEngineInstance = $installedComponents |
209+ Where-Object - FilterScript {
210+ $_.InstanceId -match ' ^MSSQL'
211+ }
225212
226- if ($isSsmsAdvancedInstalled )
213+ foreach ($currentInstance in $databaseEngineInstance )
227214 {
228- $component.Feature = ' ADV_SSMS'
215+ # Looking for installed version for Replication.
216+ $isReplicationInstalled = Test-IsReplicationInstalled - InstanceId $currentInstance.InstanceId
217+
218+ if ($isReplicationInstalled )
219+ {
220+ $installedComponents += [PSCustomObject ] @ {
221+ Feature = ' Replication'
222+ Version = $currentInstance.Version
223+ InstanceName = $currentInstance.InstanceName
224+ InstanceId = $currentInstance.InstanceId
225+ }
226+ }
227+
228+ # Looking for installed version for Replication.
229+ $isReplicationInstalled = Test-IsAdvancedAnalyticsInstalled - InstanceId $currentInstance.InstanceId
230+
231+ if ($isReplicationInstalled )
232+ {
233+ $installedComponents += [PSCustomObject ] @ {
234+ Feature = ' AdvancedAnalytics'
235+ Version = $currentInstance.Version
236+ InstanceName = $currentInstance.InstanceName
237+ InstanceId = $currentInstance.InstanceId
238+ }
239+ }
229240 }
230241
242+ # SQL_DQ_Full = DQ : Data Quality Services
243+ # sql_inst_mr = SQL_INST_MR : R Open and proprietary R packages
244+ # sql_inst_mpy = SQL_INST_MPY : Anaconda and proprietary Python packages.
245+ # SQL_Polybase_Core_Inst = PolyBaseCore : PolyBase technology
246+
247+ # $isDQInstalled = Test-IsDQComponentInstalled -InstanceName $InstanceName -SqlServerMajorVersion $sqlVersion
248+
249+ # if ($isDQInstalled)
250+ # {
251+ # $component.Feature = 'DQ'
252+ # }
253+
254+ # #$isSsmsInstalled = Test-IsSsmsInstalled -SqlServerMajorVersion $sqlVersion
255+
256+ # if ($isSsmsInstalled)
257+ # {
258+ # $component.Feature = 'SSMS'
259+ # }
260+
261+ # #$isSsmsAdvancedInstalled = Test-IsSsmsAdvancedInstalled -SqlServerMajorVersion $sqlVersion
262+
263+ # if ($isSsmsAdvancedInstalled)
264+ # {
265+ # $component.Feature = 'ADV_SSMS'
266+ # }
267+
231268
232269 # Filter result
233270
0 commit comments