So my customer needed a list of all Applications installed in their XenApp 6.0 farm. With which groups had access and number of members in each group.

So we installed the XenApp 6 Powershell SDK on a server and then I built this small script.

This is the final version of the script:

#Lets build the table to store the end result in
$table = New-Object system.Data.DataTable 'ApplicationList'
$table.columns.add((New-Object system.Data.DataColumn Application,([string])))
$table.columns.add((New-Object system.Data.DataColumn UserGroup,([string])))
$table.columns.add((New-Object system.Data.DataColumn MemberCount,([uint32])))
#Lets save all applications to a variable
$Applications = Get-XAApplication
ForEach ($App in $Applications)
{
	$groups = $Null
	$groups = Get-XAAccount -BrowserName $App.BrowserName
	if ($groups -ne $Null)
	{
		ForEach ($Group in $groups)
		{
			$row = $table.NewRow()
			$row.Application = $App.BrowserName
			$row.UserGroup = $Group.AccountName
			if ($ADGroupCounts[$Group.AccountName] -ne $Null)
			{
				$row.MemberCount = $ADGroupCounts[$Group.AccountName]
			}
			else
			{
				$row.MemberCount = 0
			}
			$table.Rows.Add($row)
		}
	}
	else
	{
		$row = $table.NewRow()
		$row.Application = $App.BrowserName
		$row.UserGroup = '-None-'
		$row.MemberCount = 0
		$table.Rows.Add($row)
	}
}

If you want all the member of membergroups you will have to change the first part to:

Import-Module ActiveDirectory
$ADGroupCounts = @{}
ForEach ($Group in (Get-ADGroup -properties Members -ResultSetSize $Unlimited -Filter *))
{
	$ADGroupCounts[$Group.Name] = get-adgroupmember -Recursive $Group | Measure-Object |Select-Object -ExpandProperty Count
}