Skip to content

Commit aeab5dd

Browse files
authored
Merge pull request #1365 from anosov1960/master
Updated to support UsePcoreLicense
2 parents 0509dfb + d836e16 commit aeab5dd

2 files changed

Lines changed: 26 additions & 7 deletions

File tree

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

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ services: Azure Arc-enabled SQL Server
33
platforms: Azure
44
author: anosov1960
55
ms.author: sashan
6-
ms.date: 9/22/2023
6+
ms.date: 12/01/2024
77
---
88

99

@@ -31,6 +31,7 @@ The script accepts the following command line parameters:
3131
|-ResourceGroup |resource_group_name|Optional: Limits the scope to a specific resource group|
3232
|-MachineName |machine_name|Optional: Limits the scope to a specific machine|
3333
|-LicenseType | "Paid", "PAYG" or "LicenseOnly"| Optional: Sets the license type to the specified value |
34+
|-UsePcoreLicense | "Yes", "No" | Optional. Enables unlimited virtualization license if the value is "Yes" or disables it if the value is "No". To enable, the license type must be "Paid" or "PAYG"|
3435
|-EnableESU | "Yes", "No" | Optional. Enables the ESU policy the value is "Yes" or disables it if the value is "No". To enable, the license type must be "Paid" or "PAYG"|
3536
|-Force| |Optional. Forces the change of the license type to the specified value on all installed extensions. If -Force is not specified, the -LicenseType value is set only if undefined. Ignored if -LicenseType is not specified|
3637

@@ -57,10 +58,10 @@ The following command will scan the subscription `<sub_id>` and set the license
5758

5859
## Example 3
5960

60-
The following command will scan resource group `<resource_group_name>` in the subscription `<sub_id>` and set the license type value to "PAYG" on all servers.
61+
The following command will scan resource group `<resource_group_name>` in the subscription `<sub_id>` and set the license type value to "PAYG" and enable unlimited virtualization license on all servers in the specified resource group.
6162

6263
```PowerShell
63-
.\modify-license-type.ps1 -SubId <sub_id> -ResourceGroup <resource_group_name> -LicenseType PAYG -Force
64+
.\modify-license-type.ps1 -SubId <sub_id> -ResourceGroup <resource_group_name> -LicenseType PAYG -UsePcoreLicense Yes -Force
6465
```
6566

6667
## Example 4

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

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,15 @@
66
# If not specified, all subscriptions your role has access to are scanned.
77
#
88
# The script accepts the following command line parameters:
9-
#
9+
#.
1010
# -SubId [subscription_id] | [csv_file_name] (Optional. Limits the scope to specific subscriptions. Accepts a .csv file with the list of subscriptions.
1111
# If not specified all subscriptions will be scanned)
1212
# -ResourceGroup [resource_goup] (Optional. Limits the scope to a specific resoure group)
1313
# -MachineName [machine_name] (Optional. Limits the scope to a specific machine)
1414
# -LicenseType [license_type_value] (Optional. Sets the license type to the specified value)
15-
# -EnableESU [Yes or No] (Optional. Enables the ESU policy the value is "Yes" or disables it if the value is "No"
15+
# -UsePcoreLicense [Yes or No] (Optional. Enables unlimited virtualization license if the value is "Yes" or disables it if the value is "No"
16+
# To enable, the license type must be "Paid" or "PAYG"
17+
# -EnableESU [Yes or No] (Optional. Enables the ESU policy if the value is "Yes" or disables it if the value is "No"
1618
# To enable, the license type must be "Paid" or "PAYG"
1719
# -Force (Optional. Forces the chnahge of the license type to the specified value on all installed extensions.
1820
# If Force is not specified, the -LicenseType value is set only if undefined. Ignored if -LicenseType is not specified
@@ -34,6 +36,9 @@ param (
3436
[string] $LicenseType,
3537
[Parameter (Mandatory= $false)]
3638
[ValidateSet("Yes","No", IgnoreCase=$false)]
39+
[string] $UsePcoreLicense,
40+
[Parameter (Mandatory= $false)]
41+
[ValidateSet("Yes","No", IgnoreCase=$false)]
3742
[string] $EnableESU,
3843
[Parameter (Mandatory= $false)]
3944
[switch] $Force
@@ -243,11 +248,24 @@ foreach ($sub in $subscriptions){
243248
write-host "The configured license type does not support ESUs"
244249
}
245250
}
246-
251+
252+
# Enable UsePcoreLicense for qualified license types or disable
253+
if ($UsePcoreLicense) {
254+
if (($settings["LicenseType"] | select-string "Paid","PAYG") -or ($UsePcoreLicense -eq "No")) {
255+
$settings["UsePhysicalCoreLicense"] = @{
256+
"IsApplied" = ($UsePcoreLicense -eq "Yes");
257+
"LastUpdatedTimestamp" = [DateTime]::UtcNow.ToString('yyyy-MM-ddTHH:mm:ss.fffZ')
258+
}
259+
$WriteSettings = $true
260+
} else {
261+
write-host "The configured license type does not support ESUs"
262+
}
263+
}
247264
If ($WriteSettings) {
248-
Write-Host "Resource group: [$($r.resourceGroup)] Connected machine: [$($r.MachineName)] : License type: [$($settings["LicenseType"])] : Enable ESU: [$($settings["enableExtendedSecurityUpdates"])]"
265+
249266
try {
250267
Set-AzConnectedMachineExtension @setId -Settings $settings -NoWait | Out-Null
268+
Write-Host "Updated -- Resource group: [$($r.resourceGroup)], Connected machine: [$($r.MachineName)]"
251269
} catch {
252270
write-host "The request to modify the extenion object failed with the following error:"
253271
write-host $_.Exception.Message

0 commit comments

Comments
 (0)