@@ -169,23 +169,13 @@ $SqlVmLicenseType = if ($LicenseType -eq "LicenseIncluded") { "PAYG" } else { "A
169169$modifiedResources = @ ()
170170
171171# Determine the subscriptions to process: CSV file, single subscription, or all accessible subscriptions.
172- try {
173- if ($SubId -and $SubId -like " *.csv" ) {
174- Write-Output " Gathering subscriptions from CSV file: $SubId "
175- $subscriptions = Import-Csv - Path $SubId
176- }
177- elseif (($null -ne $SubId ) -and $SubId -ne " " ) {
178- Write-Output " Gathering subscription details for: $SubId "
179- $subscriptions = @ (az account show -- subscription $SubId -- output json | ConvertFrom-Json )
180- }
181- else {
182- Write-Output " Gathering all accessible subscriptions..."
183- $subscriptions = az account list -- output json | ConvertFrom-Json
184- }
185- }
186- catch {
187- Write-Error " Error determining subscriptions: $_ "
188- exit 1
172+ if ($SubId -like " *.csv" ) {
173+ $subscriptions = Import-Csv $SubId
174+ }elseif ($SubId -ne " " ) {
175+ Write-Output " Passed Subscription $ ( $SubId ) "
176+ $subscriptions = Get-AzSubscription - SubscriptionId $SubId
177+ }else {
178+ $subscriptions = Get-AzSubscription | Where-Object { $_.TenantId -eq $tenantId }
189179}
190180
191181# Build resource group filter if specified.
@@ -375,13 +365,13 @@ foreach ($sub in $subscriptions) {
375365 # Collect data before modification
376366 $modifiedResources += [PSCustomObject ]@ {
377367 TenantID = $TenantId
378- SubID = $server .SubscriptionId
368+ SubID = $db .SubscriptionId
379369 ResourceName = $db.name
380370 ResourceType = $db.ResourceType
381371 Status = $db.State
382372 OriginalLicenseType = $db.licenseType
383- ResourceGroup = $server .resourceGroup
384- Location = $server .location
373+ ResourceGroup = $db .resourceGroup
374+ Location = $db .location
385375 }
386376
387377 if (-not $ReportOnly ) {
@@ -405,13 +395,13 @@ foreach ($sub in $subscriptions) {
405395 # Collect data before modification
406396 $modifiedResources += [PSCustomObject ]@ {
407397 TenantID = $TenantId
408- SubID = $server .SubscriptionId
398+ SubID = $pool .SubscriptionId
409399 ResourceName = $pool.name
410400 ResourceType = $pool.ResoureType
411401 Status = $pool.State
412402 OriginalLicenseType = $pool.licenseType
413- ResourceGroup = $server .resourceGroup
414- Location = $server .location
403+ ResourceGroup = $pool .resourceGroup
404+ Location = $pool .location
415405 }
416406
417407 if (-not $ReportOnly ) {
0 commit comments