From 6a1bea3337fe7e7ab2ac1b93f4b78d9a069353ce Mon Sep 17 00:00:00 2001 From: "Alexander (Sasha) Nosov" Date: Sun, 1 Dec 2024 15:14:24 -0800 Subject: [PATCH 1/2] Updated to support UsePcoreLicense --- .../modify-license-type.ps1 | 26 ++++++++++++++++--- 1 file changed, 22 insertions(+), 4 deletions(-) diff --git a/samples/manage/azure-arc-enabled-sql-server/modify-license-type/modify-license-type.ps1 b/samples/manage/azure-arc-enabled-sql-server/modify-license-type/modify-license-type.ps1 index 29906728..430e0d15 100644 --- a/samples/manage/azure-arc-enabled-sql-server/modify-license-type/modify-license-type.ps1 +++ b/samples/manage/azure-arc-enabled-sql-server/modify-license-type/modify-license-type.ps1 @@ -6,13 +6,15 @@ # If not specified, all subscriptions your role has access to are scanned. # # The script accepts the following command line parameters: -# +#. # -SubId [subscription_id] | [csv_file_name] (Optional. Limits the scope to specific subscriptions. Accepts a .csv file with the list of subscriptions. # If not specified all subscriptions will be scanned) # -ResourceGroup [resource_goup] (Optional. Limits the scope to a specific resoure group) # -MachineName [machine_name] (Optional. Limits the scope to a specific machine) # -LicenseType [license_type_value] (Optional. Sets the license type to the specified value) -# -EnableESU [Yes or No] (Optional. Enables the ESU policy the value is "Yes" or disables it if the value is "No" +# -EnableESU [Yes or No] (Optional. Enables the ESU policy if the value is "Yes" or disables it if the value is "No" +# To enable, the license type must be "Paid" or "PAYG" +# -UsePcoreLicense [Yes or 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" # -Force (Optional. Forces the chnahge 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 @@ -36,6 +38,9 @@ param ( [ValidateSet("Yes","No", IgnoreCase=$false)] [string] $EnableESU, [Parameter (Mandatory= $false)] + [ValidateSet("Yes","No", IgnoreCase=$false)] + [string] $UsePcoreLicense, + [Parameter (Mandatory= $false)] [switch] $Force ) @@ -243,11 +248,24 @@ foreach ($sub in $subscriptions){ write-host "The configured license type does not support ESUs" } } - + + # Enable UsePcoreLicense for qualified license types or disable + if ($UsePcoreLicense) { + if (($settings["LicenseType"] | select-string "Paid","PAYG") -or ($UsePcoreLicense -eq "No")) { + $settings["UsePhysicalCoreLicense"] = @{ + "IsApplied" = ($UsePcoreLicense -eq "Yes"); + "LastUpdatedTimestamp" = [DateTime]::UtcNow.ToString('yyyy-MM-ddTHH:mm:ss.fffZ') + } + $WriteSettings = $true + } else { + write-host "The configured license type does not support ESUs" + } + } If ($WriteSettings) { - Write-Host "Resource group: [$($r.resourceGroup)] Connected machine: [$($r.MachineName)] : License type: [$($settings["LicenseType"])] : Enable ESU: [$($settings["enableExtendedSecurityUpdates"])]" + try { Set-AzConnectedMachineExtension @setId -Settings $settings -NoWait | Out-Null + Write-Host "Updated -- Resource group: [$($r.resourceGroup)], Connected machine: [$($r.MachineName)]" } catch { write-host "The request to modify the extenion object failed with the following error:" write-host $_.Exception.Message From d836e167a4c68775532ffa4712f235fc79313847 Mon Sep 17 00:00:00 2001 From: "Alexander (Sasha) Nosov" Date: Sun, 1 Dec 2024 15:28:15 -0800 Subject: [PATCH 2/2] Modified README --- .../modify-license-type/README.md | 7 ++++--- .../modify-license-type/modify-license-type.ps1 | 8 ++++---- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/samples/manage/azure-arc-enabled-sql-server/modify-license-type/README.md b/samples/manage/azure-arc-enabled-sql-server/modify-license-type/README.md index e0282d40..8173433c 100644 --- a/samples/manage/azure-arc-enabled-sql-server/modify-license-type/README.md +++ b/samples/manage/azure-arc-enabled-sql-server/modify-license-type/README.md @@ -3,7 +3,7 @@ services: Azure Arc-enabled SQL Server platforms: Azure author: anosov1960 ms.author: sashan -ms.date: 9/22/2023 +ms.date: 12/01/2024 --- @@ -31,6 +31,7 @@ The script accepts the following command line parameters: |-ResourceGroup |resource_group_name|Optional: Limits the scope to a specific resource group| |-MachineName |machine_name|Optional: Limits the scope to a specific machine| |-LicenseType | "Paid", "PAYG" or "LicenseOnly"| Optional: Sets the license type to the specified value | +|-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"| |-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"| |-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| @@ -57,10 +58,10 @@ The following command will scan the subscription `` and set the license ## Example 3 -The following command will scan resource group `` in the subscription `` and set the license type value to "PAYG" on all servers. +The following command will scan resource group `` in the subscription `` and set the license type value to "PAYG" and enable unlimited virtualization license on all servers in the specified resource group. ```PowerShell -.\modify-license-type.ps1 -SubId -ResourceGroup -LicenseType PAYG -Force +.\modify-license-type.ps1 -SubId -ResourceGroup -LicenseType PAYG -UsePcoreLicense Yes -Force ``` ## Example 4 diff --git a/samples/manage/azure-arc-enabled-sql-server/modify-license-type/modify-license-type.ps1 b/samples/manage/azure-arc-enabled-sql-server/modify-license-type/modify-license-type.ps1 index 430e0d15..62873d8f 100644 --- a/samples/manage/azure-arc-enabled-sql-server/modify-license-type/modify-license-type.ps1 +++ b/samples/manage/azure-arc-enabled-sql-server/modify-license-type/modify-license-type.ps1 @@ -12,10 +12,10 @@ # -ResourceGroup [resource_goup] (Optional. Limits the scope to a specific resoure group) # -MachineName [machine_name] (Optional. Limits the scope to a specific machine) # -LicenseType [license_type_value] (Optional. Sets the license type to the specified value) -# -EnableESU [Yes or No] (Optional. Enables the ESU policy if the value is "Yes" or disables it if the value is "No" -# To enable, the license type must be "Paid" or "PAYG" # -UsePcoreLicense [Yes or 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" +# -EnableESU [Yes or No] (Optional. Enables the ESU policy if the value is "Yes" or disables it if the value is "No" +# To enable, the license type must be "Paid" or "PAYG" # -Force (Optional. Forces the chnahge 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 # @@ -36,10 +36,10 @@ param ( [string] $LicenseType, [Parameter (Mandatory= $false)] [ValidateSet("Yes","No", IgnoreCase=$false)] - [string] $EnableESU, + [string] $UsePcoreLicense, [Parameter (Mandatory= $false)] [ValidateSet("Yes","No", IgnoreCase=$false)] - [string] $UsePcoreLicense, + [string] $EnableESU, [Parameter (Mandatory= $false)] [switch] $Force )