mirror of
https://github.com/Microsoft/sql-server-samples.git
synced 2025-12-08 14:58:54 +00:00
Added warning suppression
This commit is contained in:
@@ -3,7 +3,7 @@ services: Azure SQL
|
||||
platforms: Azure
|
||||
author: anosov1960
|
||||
ms.author: sashan
|
||||
ms.date: 3/27/2021
|
||||
ms.date: 10/26/2022
|
||||
---
|
||||
|
||||
# Overview
|
||||
@@ -58,6 +58,8 @@ The script accepts the following command line parameters:
|
||||
|-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 with a self-hosted SQL server instance that is unregistered with the IaaS SQL extension|
|
||||
|-ShowNC|\$True or \$False (default)|Optional: causes the script to report the AHB and PAYG consumption in normalized cores (NC). For more information about normalized cores, see [How licenses apply to Azure resources](https://learn.microsoft.com/azure/cost-management-billing/scope-level/overview-azure-hybrid-benefit-scope#how-licenses-apply-to-azure-resources).|
|
||||
|
||||
|
||||
<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
|
||||
|
||||
@@ -40,7 +40,7 @@ param (
|
||||
[Parameter (Mandatory= $false)]
|
||||
[bool] $UseInRunbook = $false,
|
||||
[Parameter (Mandatory= $false)]
|
||||
[bool] $ShowEC = $false,
|
||||
[bool] $ShowNC = $false,
|
||||
[Parameter (Mandatory= $false)]
|
||||
[bool] $ShowUnregistered = $false
|
||||
|
||||
@@ -183,6 +183,11 @@ function DiscoveryOnWindows {
|
||||
Write-Output $SqlInstalled
|
||||
}
|
||||
|
||||
#
|
||||
# Suppress warnings
|
||||
#
|
||||
Update-AzConfig -DisplayBreakingChangeWarning $false
|
||||
|
||||
#
|
||||
# This script checks if SQL Server is installed on Linux
|
||||
#
|
||||
@@ -271,8 +276,8 @@ if ($useDatabase){
|
||||
[Time] [time](7) NOT NULL,
|
||||
[SubscriptionName] [nvarchar](50) NOT NULL,
|
||||
[SubscriptionID] [nvarchar](50) NOT NULL,
|
||||
[AHB_EC] [int] NULL,
|
||||
[PAYG_EC] [int] NULL,
|
||||
[AHB_NC] [int] NULL,
|
||||
[PAYG_NC] [int] NULL,
|
||||
[AHB_STD_vCores] [int] NULL,
|
||||
[AHB_ENT_vCores] [int] NULL,
|
||||
[PAYG_STD_vCores] [int] NULL,
|
||||
@@ -288,8 +293,8 @@ if ($useDatabase){
|
||||
[Time],
|
||||
[SubscriptionName],
|
||||
[SubscriptionID],
|
||||
[AHB_EC],
|
||||
[PAYG_EC],
|
||||
[AHB_NC],
|
||||
[PAYG_NC],
|
||||
[AHB_STD_vCores],
|
||||
[AHB_ENT_vCores],
|
||||
[PAYG_STD_vCores],
|
||||
@@ -324,7 +329,7 @@ if ($useDatabase){
|
||||
}
|
||||
|
||||
[System.Collections.ArrayList]$usageTable = @()
|
||||
$usageTable += ,(@("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"))
|
||||
$usageTable += ,(@("Date", "Time", "Subscription Name", "Subscription ID", "AHB NCs", "PAYG NCs", "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"))
|
||||
}
|
||||
|
||||
$global:VM_SKUs = @{} # To hold the VM SKU table for future use
|
||||
@@ -542,18 +547,18 @@ foreach ($sub in $subscriptions){
|
||||
$Date = Get-Date -Format "yyy-MM-dd"
|
||||
|
||||
$Time = Get-Date -Format "HH:mm:ss"
|
||||
if ($ShowEC){
|
||||
$ahb_ec = ($subtotal.ahb_std + $subtotal.ahb_ent*4)
|
||||
$payg_ec = ($subtotal.payg_std + $subtotal.payg_ent*4)
|
||||
if ($ShowNC){
|
||||
$ahb_nc = ($subtotal.ahb_std + $subtotal.ahb_ent*4)
|
||||
$payg_nc = ($subtotal.payg_std + $subtotal.payg_ent*4)
|
||||
}else{
|
||||
$ahb_ec = 0
|
||||
$payg_ec = 0
|
||||
$ahb_nc = 0
|
||||
$payg_nc = 0
|
||||
}
|
||||
if ($useDatabase){
|
||||
$propertiesToSplat.Query = $insertSQL -f $Date, $Time, $sub.Name, $sub.Id, $ahb_ec, $payg_ec, $subtotal.ahb_std, $subtotal.ahb_ent, $subtotal.payg_std, $subtotal.payg_ent, $subtotal.hadr_std, $subtotal.hadr_ent, $subtotal.developer, $subtotal.express, $subtotal.unreg_sqlvm, $subtotal.unknown_tier
|
||||
$propertiesToSplat.Query = $insertSQL -f $Date, $Time, $sub.Name, $sub.Id, $ahb_nc, $payg_nc, $subtotal.ahb_std, $subtotal.ahb_ent, $subtotal.payg_std, $subtotal.payg_ent, $subtotal.hadr_std, $subtotal.hadr_ent, $subtotal.developer, $subtotal.express, $subtotal.unreg_sqlvm, $subtotal.unknown_tier
|
||||
Invoke-SQLCmd @propertiesToSplat
|
||||
}else{
|
||||
$usageTable += ,(@( $Date, $Time, $sub.Name, $sub.Id, $ahb_ec, $payg_ec, $subtotal.ahb_std, $subtotal.ahb_ent, $subtotal.payg_std, $subtotal.payg_ent, $subtotal.hadr_std, $subtotal.hadr_ent, $subtotal.developer, $subtotal.express, $subtotal.unreg_sqlvm, $subtotal.unknown_tier))
|
||||
$usageTable += ,(@( $Date, $Time, $sub.Name, $sub.Id, $ahb_nc, $payg_nc, $subtotal.ahb_std, $subtotal.ahb_ent, $subtotal.payg_std, $subtotal.payg_ent, $subtotal.hadr_std, $subtotal.hadr_ent, $subtotal.developer, $subtotal.express, $subtotal.unreg_sqlvm, $subtotal.unknown_tier))
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user