Updated Get-SQLAzureArcReclassReport and Readme.md file

This commit is contained in:
Raúl Carboneras
2023-08-28 10:59:30 +02:00
parent 3d591901a7
commit 5b91b298a1
2 changed files with 80 additions and 4 deletions
@@ -1,4 +1,5 @@
# This script return a report of the instances that should return SQL Reclass from the Azure Arc servers perspective
#Requires -Modules Az.ResourceGraph, Az.ConnectedMachine, Az.Accounts
# This script returns a report of the instances that should return SQL Reclass from the Azure Arc servers perspective
# It also returns all the extension status from Arc Servers that has mssqldiscovered to true
#region Sample queries
@@ -96,7 +97,7 @@ $results = foreach ($group in $ResultsGlobalGrouped) {
# The following exports in a CSV file the servers that are effectively generating ACR (2008 is not suported)
$global:ArcSQLServerinstanceswithReclass = $results | where version -notlike *2008*
$ArcSQLServerinstanceswithReclass | Export-Csv -Path .\ArcSQLServerinstanceswithReclass.csv -Force
$ArcSQLServerinstanceswithReclass | Export-Csv -Path .\ArcSQLServerinstanceswithReclass.csv -Force -NoTypeInformation
Write-Host "Results where exported to file 'ArcSQLServerinstanceswithReclass.csv' in the local folder" -ForegroundColor Green
#endregion
@@ -111,7 +112,7 @@ $queryExtensionSatus = @"
resources
| where type =~ 'microsoft.hybridcompute/machines'
| where properties.detectedProperties.mssqldiscovered == "true"
| extend id = tolower(id), ResourceGroup = split (id,'/',8)[0], Status = properties.status
| extend id = tolower(id), ResourceGroup = split (id,'/',4)[0], Status = properties.status
| join kind = inner (resources
| where type == 'microsoft.hybridcompute/machines/extensions'
| where properties.type == "WindowsAgent.SqlServer"
@@ -125,7 +126,14 @@ Write-Host "`nQuerying status of the SQL Extensions in azure Arc servers .. `n"
$global:SQLExtensionStatus = Search-AzGraph -Query $queryExtensionSatus -First 1000
# The following exports in a CSV file the status of the SQL extension in the Azure Arc Servers
$SQLExtensionStatus | Export-Csv -Path .\SQLExtensionStatus.csv -Force
$SQLExtensionStatus | Export-Csv -Path .\SQLExtensionStatus.csv -Force -NoTypeInformation
Write-Host "Results where exported to file 'SQLExtensionStatus.csv' in the local folder" -ForegroundColor Green
# region samples
# Servers with the license not set to Paid:
#$ArcSQLServerinstanceswithReclass | where licenseTypeinGraph -ne "Paid" | Select-Object subscriptionId,resourceGroup,AzureArcServerName,Status -Unique
#Extensionstofix
#$ExtensionStatus | Out-GridView
#endregion
@@ -0,0 +1,68 @@
---
services: Azure Arc-enabled SQL Server
platforms: Azure
author: racarb
ms.date: 24/8/2023
---
# Overview
This script provides a report of the Azure Arc SQL resources that generate SQL Reclass, including the following information from each resource in a CSV format:
| **Promerty**                                                                     | **Description** |
|:--|:--|
|createdAt|The time when the Azure Arc SQL resource was created|
|subscriptionId|Id of the subscription
|resourceGroup|Resource group name
|AzureArcServerName|Azure Arc server where the SQL instance is in
|Status|Status of the SQL Instance Resource
|SQLInstanceName|SQL Instance name
|version|Version of the SQL instance
|edition| Edition of the SQL instance
|vcores|Number of cores
|licenseTypeinGraph| Licence setting's value, from Azure Graph perspective
|licenseTypeInExt|License setting's value, from the extension perspective (Powershell query)
|ExVersion| Version of the WindowsAgent.SqlServer extension
|provisioningState|Provision state of the WindowsAgent.SqlServer extension
The file is stored in the local folder with the name ***ArcSQLServerinstanceswithReclass.csv***
<br>
Aditionaly, another CSV is created with the information of all the WindowsAgent.SqlServer extensions from azure Arc Servers
| **Promerty** &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp; &nbsp; | **Description** |
|:--|:--|
|subscriptionId|Id of the subscription
|resourceGroup|Resource group name
|name|Azure Arc server where the SQL extension is installed
|Status|Status of the SQL extension
|ExVersion|Version of the SQL extension
|provisioningState|Provision state of the WindowsAgent.SqlServer extension
The information is stored in the local folder with the name ***SQLExtensionStatus.csv***
<br>
# Prerequisites
- The following powershell modules are needed: *Az.ResourceGraph, Az.ConnectedMachine, Az.Accounts*
- You must have at least a *Reader* role in each subscription from wich you want to extract the information
- You must be connected to Azure AD and logged in to your Azure account. If your account have access to multiple tenants, make sure to log in with a specific tenant ID.
# Launching the script
The script doesn't have any parameter and it is launched as is:
## Example 1
The following example gets a report from the subcriptions wich the users have access to
```PowerShell
.\Get-SQLAzureArcReclassReport.ps1
```