Skip to content

Commit 4806f96

Browse files
authored
Removed edition, added consent
1 parent 9d98f2f commit 4806f96

1 file changed

Lines changed: 22 additions & 7 deletions

File tree

samples/manage/azure-arc-enabled-sql-server/modify-license-type/modify-arc-sql-license-type.ps1

Lines changed: 22 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,10 @@ param (
6363
[ValidateSet("PAYG","Paid","LicenseOnly", IgnoreCase=$false)]
6464
[string] $LicenseType,
6565

66+
[Parameter (Mandatory= $false)]
67+
[ValidateSet("Yes","No", IgnoreCase=$false)]
68+
[string] $ConsentToRecurringPAYG,
69+
6670
[Parameter (Mandatory= $false)]
6771
[ValidateSet("Yes","No", IgnoreCase=$false)]
6872
[string] $UsePcoreLicense,
@@ -258,7 +262,7 @@ foreach ($sub in $subscriptions) {
258262
| join kind=leftouter (
259263
resources
260264
| where type == 'microsoft.azurearcdata/sqlserverinstances'
261-
| project machineName= name, edition = properties.edition, mytags = tags"
265+
| project machineName= name, mytags = tags"
262266
$query += ") on machineName"
263267

264268
if ($ResourceGroup) {
@@ -271,7 +275,7 @@ foreach ($sub in $subscriptions) {
271275
}
272276

273277
$query += "
274-
| project machineName, extensionName = name, resourceGroup, location, subscriptionId, extensionPublisher, extensionType, properties,provisioningState, edition
278+
| project machineName, extensionName = name, resourceGroup, location, subscriptionId, extensionPublisher, extensionType, properties,provisioningState
275279
"
276280
$query
277281
$resources = Search-AzGraph -Query "$($query)"
@@ -290,7 +294,6 @@ foreach ($sub in $subscriptions) {
290294
SubscriptionId = $resources[$count].subscriptionId
291295
Publisher = $resources[$count].extensionPublisher
292296
ExtensionType = $resources[$count].extensionType
293-
Edition = $resources[$count].edition
294297
}
295298

296299
write-Output "VM - $($setID.MachineName)"
@@ -357,10 +360,6 @@ foreach ($sub in $subscriptions) {
357360
}
358361
}
359362

360-
if ($setID.Edition -eq "Express") {
361-
$LicenseType = "LicenseOnly"
362-
}
363-
364363
if ($EnableESU) {
365364
if (($ext.Setting["LicenseType"] -in ("Paid","PAYG")) -or ($EnableESU -eq "No")) {
366365
$ext.Setting["enableExtendedSecurityUpdates"] = ($EnableESU -eq "Yes")
@@ -382,7 +381,23 @@ foreach ($sub in $subscriptions) {
382381
write-Output "The configured license type does not support ESUs"
383382
}
384383
}
384+
385+
# Add or update ConsentToRecurringPAYG setting if applicable
386+
if ($ConsentToRecurringPAYG -eq "Yes") {
387+
$isPayg = ($LicenseType -eq "PAYG") -or ($ext.Setting["LicenseType"] -eq "PAYG")
388+
if ($isPayg) {
389+
if (-not $ext.Setting.ContainsKey("ConsentToRecurringPAYG") -or -not $ext.Setting["ConsentToRecurringPAYG"]["Consented"]) {
390+
$ext.Setting["ConsentToRecurringPAYG"] = @{
391+
"Consented" = $true;
392+
"ConsentTimestamp" = [DateTime]::UtcNow.ToString('yyyy-MM-ddTHH:mm:ssZ')
393+
}
394+
$WriteSettings = $true
395+
}
396+
}
397+
}
398+
385399
write-Output " Write Settings - $($WriteSettings)"
400+
386401
if (-not $ReportOnly) {
387402
If ($WriteSettings) {
388403
try {

0 commit comments

Comments
 (0)