diff --git a/samples/manage/DiscoverSql.ps1 b/samples/manage/DiscoverSql.ps1 new file mode 100644 index 00000000..874a4d5c --- /dev/null +++ b/samples/manage/DiscoverSql.ps1 @@ -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 diff --git a/samples/manage/DiscoverSql.sh b/samples/manage/DiscoverSql.sh new file mode 100644 index 00000000..5b430e3a --- /dev/null +++ b/samples/manage/DiscoverSql.sh @@ -0,0 +1,6 @@ +if ! systemctl is-active --quiet mssql-server.service; then + echo "False" + exit + else + echo "True" + fi \ No newline at end of file diff --git a/samples/manage/azure-hybrid-benefit/README.md b/samples/manage/azure-hybrid-benefit/README.md index 99344ff4..fb51710a 100644 --- a/samples/manage/azure-hybrid-benefit/README.md +++ b/samples/manage/azure-hybrid-benefit/README.md @@ -57,7 +57,7 @@ The script accepts the following command line parameters: |-Database|database_name|Optional: database name where data will be saved.
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| 1You can create a .csv file using the following command and then edit to remove the subscriptions you don't want to scan. ```PowerShell diff --git a/samples/manage/azure-hybrid-benefit/sql-license-usage.ps1 b/samples/manage/azure-hybrid-benefit/sql-license-usage.ps1 index d32e4bc4..950809ec 100644 --- a/samples/manage/azure-hybrid-benefit/sql-license-usage.ps1 +++ b/samples/manage/azure-hybrid-benefit/sql-license-usage.ps1 @@ -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){ diff --git a/samples/manage/sql-license-usage.csv b/samples/manage/sql-license-usage.csv new file mode 100644 index 00000000..05f1bf3d --- /dev/null +++ b/samples/manage/sql-license-usage.csv @@ -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"