|
31 | 31 | # The script accepts the following command line parameters: |
32 | 32 | # |
33 | 33 | # -SubId [subscription_id] | [csv_file_name] (Accepts a .csv file with the list of subscriptions) |
34 | | -# -UseInRunbook [True] | [False] (Required when executed as a Runbook) |
35 | 34 | # -Server [protocol:]server[instance_name][,port] (Required to save data to the database) |
36 | 35 | # -Database [database_name] (Required to save data to the database) |
37 | 36 | # -Cred [credential_object] (Required to save data to the database) |
38 | 37 | # -FilePath [csv_file_name] (Required to save data in a .csv format. Ignored if database parameters are specified) |
39 | | -# |
| 38 | +# -UseInRunbook [True] | [False] (Required when executed as a Runbook) |
40 | 39 | # |
41 | 40 |
|
42 | 41 | param ( |
@@ -84,7 +83,7 @@ function CheckModule ($m) { |
84 | 83 | } |
85 | 84 |
|
86 | 85 | function GetVCores { |
87 | | - # This function translates each VM or Host sku typo and name into vCores |
| 86 | + # This function translates each VM or Host sku type and name into vCores |
88 | 87 |
|
89 | 88 | [CmdletBinding()] |
90 | 89 | param ( |
@@ -114,7 +113,7 @@ function GetVCores { |
114 | 113 | } |
115 | 114 | } |
116 | 115 | function AddVCores { |
117 | | - # This function populets the $subtotal nubmers |
| 116 | + # This function breaks down vCores into the $subtotal columns |
118 | 117 |
|
119 | 118 | [CmdletBinding()] |
120 | 119 | param ( |
@@ -264,7 +263,7 @@ if ($SubId -like "*.csv") { |
264 | 263 |
|
265 | 264 | [bool] $useDatabase = $PSBoundParameters.ContainsKey("Server") -and $PSBoundParameters.ContainsKey("Cred") -and $PSBoundParameters.ContainsKey("Database") |
266 | 265 |
|
267 | | -#Initialize tables and arrays |
| 266 | +# Initialize tables and arrays |
268 | 267 |
|
269 | 268 | if ($useDatabase){ |
270 | 269 |
|
@@ -363,42 +362,42 @@ foreach ($sub in $subscriptions){ |
363 | 362 | # Get all resource groups in the subscription |
364 | 363 | $rgs = Get-AzResourceGroup |
365 | 364 |
|
366 | | - #Get all logical servers |
| 365 | + # Get all logical servers |
367 | 366 | $servers = Get-AzSqlServer |
368 | 367 |
|
369 | | - #Scan all vCore-based SQL database resources in the subscription |
| 368 | + # Scan all vCore-based SQL database resources in the subscription |
370 | 369 | $servers | Get-AzSqlDatabase | Where-Object { $_.SkuName -ne "ElasticPool" -and $_.Edition -in "GeneralPurpose", "BusinessCritical", "Hyperscale"} | Foreach-Object { |
371 | 370 | AddVCores -Tier $_.Edition -LicenseType $_.LicenseType -CoreCount $_.Capacity |
372 | 371 | } |
373 | 372 | [system.gc]::Collect() |
374 | 373 |
|
375 | | - #Scan all vcOre-based SQL elastic pool resources in the subscription |
| 374 | + # Scan all vcOre-based SQL elastic pool resources in the subscription |
376 | 375 | $servers | Get-AzSqlElasticPool | Where-Object { $_.Edition -in "GeneralPurpose", "BusinessCritical", "Hyperscale"} | Foreach-Object { |
377 | 376 | AddVCores -Tier $_.Edition -LicenseType $_.LicenseType -CoreCount $_.Capacity |
378 | 377 | } |
379 | 378 | [system.gc]::Collect() |
380 | 379 |
|
381 | | - #Scan all SQL managed instance resources in the subscription |
| 380 | + # Scan all SQL managed instance resources in the subscription |
382 | 381 | Get-AzSqlInstance | Where-Object { $_.InstancePoolName -eq $null} | Foreach-Object { |
383 | 382 | AddVCores -Tier $_.Sku.Tier -LicenseType $_.LicenseType -CoreCount $_.VCores |
384 | 383 | } |
385 | 384 | [system.gc]::Collect() |
386 | 385 |
|
387 | | - #Scan all instance pool resources in the subscription |
| 386 | + # Scan all instance pool resources in the subscription |
388 | 387 | Get-AzSqlInstancePool | Foreach-Object { |
389 | 388 | AddVCores -Tier $_.Edition -LicenseType $_.LicenseType -CoreCount $_.VCores |
390 | 389 | } |
391 | 390 | [system.gc]::Collect() |
392 | 391 |
|
393 | | - #Scan all SSIS imtegration runtime resources in the subscription |
| 392 | + # Scan all SSIS imtegration runtime resources in the subscription |
394 | 393 | $rgs | Get-AzDataFactoryV2 | Get-AzDataFactoryV2IntegrationRuntime | Where-Object { $_.State -eq "Started" -and $_.Nodesize -ne $null } | Foreach-Object { |
395 | 394 | $vCores = GetVCores -type "virtualMachines" -name $_.NodeSize |
396 | 395 | AddVCores -Tier $_.Edition -LicenseType $_.LicenseType -CoreCount $vCores |
397 | 396 | } |
398 | 397 | [system.gc]::Collect() |
399 | 398 |
|
400 | | - #Scan all VMs with SQL server installed using a parallel loop (up to 10 at a time). For that reason function AddVCores is not used |
401 | | - #NOTE: ForEach-Object -Parallel is not supported in Runbooks (requires PS v7.1) |
| 399 | + # Scan all VMs with SQL server installed using a parallel loop (up to 10 at a time). For that reason function AddVCores is not used |
| 400 | + # NOTE: ForEach-Object -Parallel is not supported in Runbooks (requires PS v7.1) |
402 | 401 | if ($PSVersionTable.PSVersion.Major -ge 7){ |
403 | 402 | $vms = Get-AzVM -Status | Where-Object { $_.powerstate -eq 'VM running' } | ForEach-Object -ThrottleLimit 10 -Parallel { |
404 | 403 | $function:GetVCores = $using:GetVCoresDef |
|
0 commit comments