@@ -249,35 +249,40 @@ foreach ($sub in $subscriptions) {
249249 }
250250
251251 Write-Output " Collecting list of resources to update"
252+
252253 $query = "
253254 resources
254- | where type =~ 'microsoft.hybridcompute/machines/extensions'
255- | where subscriptionId =~ '$ ( $sub.Id ) '
256- | extend extensionPublisher = tostring(properties.publisher),
257- extensionType = tostring(properties.type), provisioningState = tostring(properties.provisioningState)
258- | parse id with * '/providers/Microsoft.HybridCompute/machines/' machineName '/extensions/' *
259- | where extensionPublisher =~ 'Microsoft.AzureData'
260- | where provisioningState =~ 'Succeeded'
261- | where properties.settings.LicenseType!='$LicenseType '
262- | join kind=leftouter (
263- resources
264- | where type == 'microsoft.azurearcdata/sqlserverinstances'
265- | project machineName= name, mytags = tags"
266- $query += " ) on machineName"
267-
255+ | where type == " microsoft.hybridcompute/ machines"
256+ | where properties.detectedProperties.mssqldiscovered == 'true'
257+ "
268258 if ($ResourceGroup ) {
269259 $query += " | where resourceGroup =~ '$ ( $ResourceGroup ) '"
270260 }
271261
272262 if ($machineNames.Count -gt 0 ) {
273263 $machineFilter = $machineNames | ForEach-Object { " '$_ '" } | -join " , "
274- $query += " | where machineName in~ ($machineFilter )"
264+ $query += " | where name in~ ($machineFilter )"
275265 }
276-
266+
277267 $query += "
278- | project machineName, extensionName = name, resourceGroup, location, subscriptionId, extensionPublisher, extensionType, properties,provisioningState
268+ | extend machineId = tolower(tostring(id))
269+ | project machineId, Machine_name = name
270+ | join kind= inner (
271+ resources
272+ | where type == " microsoft.hybridcompute/ machines/ extensions"
273+ | where properties.publisher =~ 'Microsoft.AzureData'
274+ | where properties.provisioningState == 'Succeeded'
275+ | where properties.settings.LicenseType!='$LicenseType '
276+ | extend extensionName = name
277+ | extend extensionPublisher = properties.publisher
278+ | extend extensionType = properties.type
279+ | parse id with '/subscriptions/' subscriptionId '/resourceGroups/' resourceGroup '/providers/Microsoft.HybridCompute/machines/' machineName '/extensions/' extensionName
280+ ) on $left .machineName == $right .machineName
281+ | project machineName, extensionName, resourceGroup, location, subscriptionId, extensionPublisher, extensionType
279282 "
280- $query
283+
284+ Write-Output $query
285+
281286 $resources = Search-AzGraph - Query " $ ( $query ) "
282287 Write-Output " Found $ ( $resources.Count ) resource(s) to update"
283288 $count = $resources.Count
0 commit comments