Hosted Apps and Desktops - How to Fix Duplicate Offering Names

Hosted Apps and Desktops - How to Fix Duplicate Offering Names

Overview

This article provides steps on how to fix the specific error message below when discovering offerings on the HAaD Offering Management Page.

Error Messages




Scan duplicate offerings in Citrix server

Use the Powershell script below and compare the Keys if it matches the Value(s) from the database.
  1. Add-PSSnapin Citrix.Broker.Admin.V2

  2. $DeliveryGroups = Get-BrokerDesktopGroup

  3. ForEach($DeliveryGroup in $DeliveryGroups) {
  4.     [PSObject[]]$Offerings  = @()
  5.     [String[]]$OfferingKeys = $DeliveryGroup.MetadataMap.Keys | Where { $_ -notmatch '&' -and $_ -ne 'Version' }

  6.     ForEach($Key in $OfferingKeys) {
  7.         $Offering = New-Object -TypeName PSObject -Property @{
  8.             Key       = $Key
  9.             Name      = $DeliveryGroup.MetadataMap[$Key]
  10.             Duplicate = If($DeliveryGroup.MetadataMap[$Key] -in $Offerings.Name) { 
  11.                             $Offerings | Where { $_.Name -eq $DeliveryGroup.MetadataMap[$Key] } `
  12.                             | ForEach { $_.Duplicate = $true }
  13.                             $true
  14.                         } Else {
  15.                             $false
  16.                         }
  17.         }

  18.         $Offerings += $Offering
  19.     }

  20.     If($Offerings.Duplicate -contains $True) {
  21.         Write-Host "Found duplicates for Delivery Group!`nDelivery Group: [Uid: $($DeliveryGroup.Uid) | Name: $($DeliveryGroup.Name)]" -ForegroundColor Red
  22.         $Offerings | Where { $_.Duplicate -eq $true } | FT
  23.     }

Example output:


In this case, there is a duplicate offering name 'Windows Server 2019'. 
Take note of the Delivery Group's Uid and the Keys (GUID) to compare it later to find which one is still valid.

Query from database the offerings and associated GUID

Use SQL script below and take note of the Value(s).
  1. use olm
  2. select p.[Label], pr.[Name], pv.[Value]
  3. from Plans p
  4. join PropertyValues pv on pv.ObjectID = p.ObjectId
  5. join Properties pr on pr.PropertyID = pv.PropertyID
  6. where p.[Label] is not null
  7. and pr.[Name] = 'CitrixAppId'
  8. and p.[Label] like '%appname%'  --> Search application name with duplicate


In the result, the valid GUID that was configured in Atria is shown.


Remove or rename duplicate offering name in Citrix server

For the example above, one of the values is not valid anymore. Execute below Powershell command to delete invalid metadata item:
  1. Get-BrokerDesktopGroup -Uid [Uid] | Remove-BrokerDesktopGroupMetadata -Name '[Key]'
Example:
  1. Get-BrokerDesktopGroup -Uid 1 | Remove-BrokerDesktopGroupMetadata -Name '203404f4-c59a-4302-8579-4d635c84e203'


Optional: For application offerings, there is a RelatedId key associated with the offering.
  1. Get-BrokerDesktopGroup -Uid [Uid] | Remove-BrokerDesktopGroupMetadata -Name '[Key]&RelatedId'
Example:
  1. Get-BrokerDesktopGroup -Uid 1 | Remove-BrokerDesktopGroupMetadata -Name '203404f4-c59a-4302-8579-4d635c84e203&RelatedId'
You can verify if there is a RelatedId key associated by executing below script:
  1. $Uid  = [Uid]
  2. $GUID = "[Key]"
  3. $DGrp = Get-BrokerDesktopGroup -Uid $Uid
  4. $Keys = $DGrp.MetadataMap.Keys | Where { $_ -match $GUID }
  5. $Keys | ForEach { 
  6.     New-Object -TypeName PSObject -Property @{
  7.         Key   = $_
  8.         Value = $DGrp.MetadataMap[$_]
  9.     } 
  10. }
Example output:



If the value(s) is still valid, you can change the value of the offering name using the below command:
  1. Set-BrokerDesktopGroupMetadata -DesktopGroupId [Uid] -Name ‘[Key]' -Value "[Correct name]" 
Example:
  1. Set-BrokerDesktopGroupMetadata -DesktopGroupId 1 -Name ‘203404f4-c59a-4302-8579-4d635c84e203' -Value "Windows 10"