Public/Get-XA7ApplicationList.ps1
<#
.SYNOPSIS Retrieves a list of enabled applications from XenApp 7 along with their associated delivery groups and other relevant details. .DESCRIPTION This function queries XenApp 7 servers for applications that are enabled and lists them along with associated delivery groups, user groups, and server counts. .PARAMETER ComputerName The address of the admin server for the Citrix environment from where the data is to be fetched. .PARAMETER ExportToCsv Specifies whether to export the output to a CSV file. The default is $false. .EXAMPLE Get-XA7ApplicationList -ComputerName "ServerAddress" Lists all enabled applications on the specified XenApp 7 server. .EXAMPLE Get-XA7ApplicationList -ComputerName "ServerAddress" -ExportToCsv $true Lists all enabled applications and exports the data to a CSV file. .NOTES Requires Citrix PowerShell SDK and appropriate administrative credentials. #> Function Get-XA7ApplicationList { param ( [Parameter(Mandatory = $true, ValueFromPipeline = $true)] [string]$ComputerName, [Parameter(Mandatory = $false)] [bool]$ExportToCsv = $false ) process { # Adding Citrix PowerShell snap-in is assumed to be done outside this function. $DeliveryGroups = Get-BrokerDesktopGroup -SessionSupport MultiSession -AdminAddress $ComputerName $applications = Get-BrokerApplication -AdminAddress $ComputerName | Where-Object {$_.Enabled -eq "True"} | ForEach-Object { $App = $_ $DGs = $DeliveryGroups | Where-Object {$App.AssociatedDesktopGroupUids -contains $_.Uid} foreach ($DG in $DGs) { $AssociatedAppsFiltered = if ($null -eq $App.AssociatedUserNames) { $x = Get-BrokerAccessPolicyRule -DesktopGroupName $DG.Name -AllowedConnections ViaAG ($x.IncludedUsers.Name | Where-Object {@('AMERICAS\CitrixApplicationAccess') -notcontains $_}) -join ', ' } else { ($App.AssociatedUserNames | Where-Object {@('AMERICAS\CitrixApplicationAccess') -notcontains $_}) -join ', ' } [PSCustomObject]@{ HostedOn = "XenApp 7" DeliveryGroup = $DG.Name ApplicationName = $App.ApplicationName Enabled = $App.Enabled GroupName = $AssociatedAppsFiltered TotalServers = $DG.TotalDesktops } } } if ($ExportToCsv) { $path = "C:\temp\CitrixApps_$(Get-Date -Format 'MM-dd-yyyy').csv" $applications | Export-Csv -Path $path -NoTypeInformation -Append Write-Host "Data exported to $path" } else { $applications } } } |