Skip to content

Commit 6a1bea3

Browse files
authored
Updated to support UsePcoreLicense
1 parent 0509dfb commit 6a1bea3

1 file changed

Lines changed: 22 additions & 4 deletions

File tree

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+
# -EnableESU [Yes or No] (Optional. Enables the ESU policy 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+
# -UsePcoreLicense [Yes or No] (Optional. Enables unlimited virtualization license 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
@@ -36,6 +38,9 @@ param (
3638
[ValidateSet("Yes","No", IgnoreCase=$false)]
3739
[string] $EnableESU,
3840
[Parameter (Mandatory= $false)]
41+
[ValidateSet("Yes","No", IgnoreCase=$false)]
42+
[string] $UsePcoreLicense,
43+
[Parameter (Mandatory= $false)]
3944
[switch] $Force
4045
)
4146

@@ -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)