Asked and (poorly) answered...
Every time someone who doesn’t understand technology talks about AI they seem to have a similar take…it’s come this far this fast, imagine the next five to ten years!
I would suggest that ten steps towards the wall does not carry with it the certainty of infinite progress you might think. Looking up often helps gain context.
So lets check in with AI once again for a simple test. The prompt is not complicated, and should be something someone who actively uses powershell and Citrix should be able to do in a short amount of time
Lets see what we get…Gemini, you are up first…we wont be including any superflous post text telling us we need to install the powershell module or reminding us that you can just go use the console to find out the information…lets just look at the code.
# Import the Citrix PowerShell module
Import-Module Citrix*
# Get the application name you want to check
$ApplicationName = "YourApplicationName"
# Get all delivery groups
$DeliveryGroups = Get-BrokerDesktopGroup
# Find the application in each delivery group and get its priority
foreach ($DeliveryGroup in $DeliveryGroups) {
$ApplicationInGroup = Get-BrokerApplication -DeliveryGroupName $DeliveryGroup.Name | Where-Object {$_.Name -eq $ApplicationName}
if ($ApplicationInGroup) {
$Priority = $ApplicationInGroup.AssociatedDesktopGroupPriorities[0]
Write-Host "Application '$ApplicationName' is published to Delivery Group '$($DeliveryGroup.Name)' with priority $Priority"
}
}
First test, first fail…Get-BrokerApplication does not have a parameter -DeliveryGroupName, and even if it did, listing out AssociatedDesktopGroupPriorities is just going to list an array of numbers, which is…not useful…
Google gets to fail twice! Lets just search google for “Citrix cloud powershell list delivery group priority sdk” i couldn’t get it to generate an AI response without the “sdk” bit, so not the exact same prompt, but the closest i could get and still have it generate a AI response and not just web results.
# Import the Citrix PowerShell module
Import-Module Citrix.AD.Broker
# Get all delivery groups and their priorities
$deliveryGroups = Get-BrokerDesktopGroup
# Loop through and display delivery group names and priorities
foreach ($group in $deliveryGroups) {
Write-Output "Delivery Group: $($group.Name), Priority: $($group.Priority)"
}
I don’t even…what is this? Again, the Priority attribute does not exist so this will never work…and the module…but…why?
Just…Add-PSSnapin Citrix* and stop making it weird…
Ok copilot…you’re next…
# Load the Citrix PowerShell snap-in
Add-PSSnapin Citrix*
# Specify the application name
$appName = "YourApplicationName"
# Get the application's associated delivery groups
$app = Get-BrokerApplication -Name $appName
$deliveryGroups = Get-BrokerApplication -Name $appName | Select-Object -ExpandProperty AssociatedDesktopGroupUids
# Iterate through each delivery group and get the priority
foreach ($dgUid in $deliveryGroups) {
$deliveryGroup = Get-BrokerDesktopGroup -Uid $dgUid
$priority = $app.AssociatedDesktopGroupPriorities[$dgUid]
Write-Output "Delivery Group: $($deliveryGroup.Name), Priority: $priority"
}
Closer…but still wrong. It’s trying to index the prority array using the delivery group Uid. So the AssociatedDesktopGroupPriorities is going to contain something like “0,0,1” and the AssociatedDesktopGroupUids is going to containg something like “45,62,78” and if you hit up Get-BrokerDesktopGroup -Uid 45it will give you information about that delivery group. So it’s…wandering nearer the correct direction than Gemini did, but still, utterly useless, if you know how to fix this, you could have written it faster without it. ChatGTP 4o is up next…that is the paid model as of writing.
# Import the Citrix PowerShell snap-in
Add-PSSnapin Citrix.Broker.Admin.V2 -ErrorAction SilentlyContinue
# Define the application name to query
$ApplicationName = "YourApplicationName" # Replace with the name of the application
# Get the application details
$Application = Get-BrokerApplication -Name $ApplicationName
if (-not $Application) {
Write-Error "Application '$ApplicationName' not found."
exit 1
}
# Display application details
Write-Output "Application: $ApplicationName"
# Get the associated delivery groups and their priorities
$AssignedDeliveryGroups = Get-BrokerAccessPolicyRule -ApplicationUid $Application.Uid | `
Select-Object -Property DesktopGroupName, Priority
if ($AssignedDeliveryGroups) {
Write-Output "Delivery Groups and Priorities:"
$AssignedDeliveryGroups | Format-Table -Property DesktopGroupName, Priority -AutoSize
} else {
Write-Output "No delivery groups are associated with this application."
}
Hands down the most code generated, and I DO appreciate an attempt to make pretty output…if only that output…existed…
Three models, three different modules imported to do the job. That isn’t a fault, just funny. The fault however, I mean there are a few, but the showstopper is Get-BrokerAccessPolicyRule
I have no idea why it thinks the access policy rule is where the priority is located, but it isn’t…and again -ApplicationUid is not a valid parameter for the cmdlet…again fixing this would be harder and require as much knowledge as writing it yourself…
I guess my job is safe for another quarter…the super complex code that DOES work btw is this:
Add-PSSnapin citrix*
$uids = Get-BrokerDesktopGroup | select PublishedName,Uid
$application = Get-BrokerApplication -Name "Web\WorkDay"
$i = 0
foreach($item in $application.AllAssociatedDesktopGroupUids) {
Write-Host ("Group: - Priority " -f (($uids | Where-Object{ $_.Uid -eq $item}).PublishedName,$application.AssociatedDesktopGroupPriorities[$i]))
$i++
}
Well, ok, I say works but, there is another unrelated issue but that has to do with the structure of the data. It turns out AllAssociatedDesktopGroupUids and AssociatedDesktopGroupPriorities are not in the same order so, its kind of useless…which, if Ai can’t figure out how to do the base task, it damn sure wont know that is it broken at a structural level…I guess my job is safe for six more months!
XenServer Appliance Import Fails
If you find your import sitting at "Connecting..." with a reference to the specific VDI it is trying to create at the end, 99% chance it failed to get an IP. At the last phase of the import just specify a static IP, in my case for whatever reason DHCP wasn't responding fast enough so even though it LOOKED like it was getting an IP it just wasn't making the connection. Manually setting an IP solved it.