Skip to content

Commit 5b91b29

Browse files
committed
Updated Get-SQLAzureArcReclassReport and Readme.md file
1 parent 3d59190 commit 5b91b29

File tree

2 files changed

+80
-4
lines changed

2 files changed

+80
-4
lines changed

samples/manage/azure-arc-enabled-sql-server/report-reclass&extensionstatus/Get-SQLAzureArcReclassReport.ps1

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
# This script return a report of the instances that should return SQL Reclass from the Azure Arc servers perspective
1+
#Requires -Modules Az.ResourceGraph, Az.ConnectedMachine, Az.Accounts
2+
# This script returns a report of the instances that should return SQL Reclass from the Azure Arc servers perspective
23
# It also returns all the extension status from Arc Servers that has mssqldiscovered to true
34

45
#region Sample queries
@@ -96,7 +97,7 @@ $results = foreach ($group in $ResultsGlobalGrouped) {
9697

9798
# The following exports in a CSV file the servers that are effectively generating ACR (2008 is not suported)
9899
$global:ArcSQLServerinstanceswithReclass = $results | where version -notlike *2008*
99-
$ArcSQLServerinstanceswithReclass | Export-Csv -Path .\ArcSQLServerinstanceswithReclass.csv -Force
100+
$ArcSQLServerinstanceswithReclass | Export-Csv -Path .\ArcSQLServerinstanceswithReclass.csv -Force -NoTypeInformation
100101
Write-Host "Results where exported to file 'ArcSQLServerinstanceswithReclass.csv' in the local folder" -ForegroundColor Green
101102
#endregion
102103

@@ -111,7 +112,7 @@ $queryExtensionSatus = @"
111112
resources
112113
| where type =~ 'microsoft.hybridcompute/machines'
113114
| where properties.detectedProperties.mssqldiscovered == "true"
114-
| extend id = tolower(id), ResourceGroup = split (id,'/',8)[0], Status = properties.status
115+
| extend id = tolower(id), ResourceGroup = split (id,'/',4)[0], Status = properties.status
115116
| join kind = inner (resources
116117
| where type == 'microsoft.hybridcompute/machines/extensions'
117118
| where properties.type == "WindowsAgent.SqlServer"
@@ -125,7 +126,14 @@ Write-Host "`nQuerying status of the SQL Extensions in azure Arc servers .. `n"
125126
$global:SQLExtensionStatus = Search-AzGraph -Query $queryExtensionSatus -First 1000
126127

127128
# The following exports in a CSV file the status of the SQL extension in the Azure Arc Servers
128-
$SQLExtensionStatus | Export-Csv -Path .\SQLExtensionStatus.csv -Force
129+
$SQLExtensionStatus | Export-Csv -Path .\SQLExtensionStatus.csv -Force -NoTypeInformation
129130
Write-Host "Results where exported to file 'SQLExtensionStatus.csv' in the local folder" -ForegroundColor Green
130131

132+
# region samples
133+
# Servers with the license not set to Paid:
134+
#$ArcSQLServerinstanceswithReclass | where licenseTypeinGraph -ne "Paid" | Select-Object subscriptionId,resourceGroup,AzureArcServerName,Status -Unique
131135

136+
#Extensionstofix
137+
#$ExtensionStatus | Out-GridView
138+
139+
#endregion
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
---
2+
services: Azure Arc-enabled SQL Server
3+
platforms: Azure
4+
author: racarb
5+
ms.date: 24/8/2023
6+
---
7+
8+
9+
# Overview
10+
11+
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:
12+
13+
14+
15+
| **Promerty**                                                                     | **Description** |
16+
|:--|:--|
17+
|createdAt|The time when the Azure Arc SQL resource was created|
18+
|subscriptionId|Id of the subscription
19+
|resourceGroup|Resource group name
20+
|AzureArcServerName|Azure Arc server where the SQL instance is in
21+
|Status|Status of the SQL Instance Resource
22+
|SQLInstanceName|SQL Instance name
23+
|version|Version of the SQL instance
24+
|edition| Edition of the SQL instance
25+
|vcores|Number of cores
26+
|licenseTypeinGraph| Licence setting's value, from Azure Graph perspective
27+
|licenseTypeInExt|License setting's value, from the extension perspective (Powershell query)
28+
|ExVersion| Version of the WindowsAgent.SqlServer extension
29+
|provisioningState|Provision state of the WindowsAgent.SqlServer extension
30+
31+
The file is stored in the local folder with the name ***ArcSQLServerinstanceswithReclass.csv***
32+
33+
<br>
34+
35+
36+
Aditionaly, another CSV is created with the information of all the WindowsAgent.SqlServer extensions from azure Arc Servers
37+
38+
| **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** |
39+
|:--|:--|
40+
|subscriptionId|Id of the subscription
41+
|resourceGroup|Resource group name
42+
|name|Azure Arc server where the SQL extension is installed
43+
|Status|Status of the SQL extension
44+
|ExVersion|Version of the SQL extension
45+
|provisioningState|Provision state of the WindowsAgent.SqlServer extension
46+
47+
The information is stored in the local folder with the name ***SQLExtensionStatus.csv***
48+
49+
<br>
50+
51+
# Prerequisites
52+
53+
- The following powershell modules are needed: *Az.ResourceGraph, Az.ConnectedMachine, Az.Accounts*
54+
- You must have at least a *Reader* role in each subscription from wich you want to extract the information
55+
- 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.
56+
57+
58+
# Launching the script
59+
60+
The script doesn't have any parameter and it is launched as is:
61+
62+
## Example 1
63+
64+
The following example gets a report from the subcriptions wich the users have access to
65+
66+
```PowerShell
67+
.\Get-SQLAzureArcReclassReport.ps1
68+
```

0 commit comments

Comments
 (0)