Fixed GetVcores

This commit is contained in:
anosov1960
2021-03-25 23:24:07 -07:00
parent a76d8558ff
commit 71d55e9e3c
5 changed files with 26 additions and 4 deletions
+11
View File
@@ -0,0 +1,11 @@
# This script checks if SQL Server is installed on Windows
[bool] $SqlInstalled = $false
$regPath = 'HKLM:\SOFTWARE\Microsoft\Microsoft SQL Server'
if (Test-Path $regPath) {
$inst = (get-itemproperty $regPath).InstalledInstances
$SqlInstalled = ($inst.Count -gt 0)
}
Write-Output $SqlInstalled
+6
View File
@@ -0,0 +1,6 @@
if ! systemctl is-active --quiet mssql-server.service; then
echo "False"
exit
else
echo "True"
fi
@@ -57,7 +57,7 @@ The script accepts the following command line parameters:
|-Database|database_name|Optional: database name where data will be saved.<br> Must be accompanied by -Server and -Cred|
|-Cred|credential_object|Optional: value of type PSCredential to securely pass database user and password|
|-FilePath|csv_file_name|Optional: filename where the data will be saved in a .csv format. Ignored if database parameters are specified|
|-ShowUnregistered|\$True or \$False (default)|Optional: causes the script to report the total size of VMs that self-host SQL server instance that is unregistered with the IaaS SQL extension|
|-ShowUnregistered|\$True or \$False (default)|Optional: causes the script to report the total size of VMs with a self-hosted SQL server instance that is unregistered with the IaaS SQL extension|
<sup>1</sup>You can create a .csv file using the following command and then edit to remove the subscriptions you don't want to scan.
```PowerShell
@@ -28,7 +28,7 @@
param (
[Parameter (Mandatory= $false)]
[string] $SubId = '4f6d3845-d3e3-4c31-bdf0-c73464aaff0e',
[string] $SubId,
[Parameter (Mandatory= $false)]
[string] $Server,
[Parameter (Mandatory= $false)]
@@ -88,7 +88,7 @@ function GetVCores {
$global:VM_SKUs = Get-AzComputeResourceSku "westus" | where-object {$_.ResourceType -in 'virtualMachines','hostGroups/hosts'}
}
# Select first size and get the VCPus available
$size_info = $global:VM_SKUs | Where-Object {$_.ResourceType.Contains($type) -and $_.Name.Contains($name)} | Select-Object -First 1
$size_info = $global:VM_SKUs | Where-Object {$_.ResourceType.Contains($type) -and ($_.Name -eq $name)} | Select-Object -First 1
# Save the VCPU count
switch ($type) {
@@ -254,7 +254,7 @@ if ($SubId -like "*.csv") {
[bool] $useDatabase = $PSBoundParameters.ContainsKey("Server") -and $PSBoundParameters.ContainsKey("Cred") -and $PSBoundParameters.ContainsKey("Database")
# Initialize tables and arrays
# Initialize tables and arraystype
if ($useDatabase){
+5
View File
@@ -0,0 +1,5 @@
"Date","Time","Subscription Name","Subscription ID","AHB ECs","PAYG ECs","AHB Std vCores","AHB Ent vCores","PAYG Std vCores","PAYG Ent vCores","HADR Std vCores","HADR Ent vCores","Developer vCores","Express vCores","Unregistered vCores","Unknown vCores"
"2021-03-25","23:03:34","SQL AHB test subscription","b503c0c6-61ce-46ac-9f16-0e5e1d8e2102","0","0","10","4","0","2","0","0","0","0","0","0"
"2021-03-25","23:04:21","Microsoft Azure Enterprise","ef2392d5-903c-445a-89a0-b64bc7d48cf5","0","0","0","0","0","0","0","0","0","0","0","0"
"2021-03-25","23:16:43","SQL AHB test subscription","b503c0c6-61ce-46ac-9f16-0e5e1d8e2102","0","0","10","4","0","8","0","0","0","0","0","0"
"2021-03-25","23:16:53","Microsoft Azure Enterprise","ef2392d5-903c-445a-89a0-b64bc7d48cf5","0","0","0","0","0","0","0","0","0","0","0","0"
1 Date Time Subscription Name Subscription ID AHB ECs PAYG ECs AHB Std vCores AHB Ent vCores PAYG Std vCores PAYG Ent vCores HADR Std vCores HADR Ent vCores Developer vCores Express vCores Unregistered vCores Unknown vCores
2 2021-03-25 23:03:34 SQL AHB test subscription b503c0c6-61ce-46ac-9f16-0e5e1d8e2102 0 0 10 4 0 2 0 0 0 0 0 0
3 2021-03-25 23:04:21 Microsoft Azure Enterprise ef2392d5-903c-445a-89a0-b64bc7d48cf5 0 0 0 0 0 0 0 0 0 0 0 0
4 2021-03-25 23:16:43 SQL AHB test subscription b503c0c6-61ce-46ac-9f16-0e5e1d8e2102 0 0 10 4 0 8 0 0 0 0 0 0
5 2021-03-25 23:16:53 Microsoft Azure Enterprise ef2392d5-903c-445a-89a0-b64bc7d48cf5 0 0 0 0 0 0 0 0 0 0 0 0