Application virtualization, IoT and Cloud Computing, Blog of Sacha Thomet

PowerShell

Check Citrix XenApp published application properties with a PowerShell script

To avoid troubles with session sharing, you have to keep in mind that you set the application properties which are relevant for the session and his virtual channels in the same way.
This is for example the properties like color depth or the audio setting.

To check this, I’ve written a small PS script which loops trough all application, reads the application properties and shout if something is not like expected.

Show all apps which are not published as 32bit Color:

#========================================================================
# Created on: 5.11.2013 
# Created by: Sacha T. http://blog.sachathomet.ch 
# Filename: apps_not32bit_Office.ps1
#========================================================================
write-host "This Script show all Apps in Workergroup National which are not in 32 bit color depth published"
Add-PSSnapin Citrix.XenApp.Commands

 #$applications = Get-XAApplication #Gets the published applications
 $applications = Get-XAApplication -WorkerGroupName National


foreach($app in $applications){
 
 #Check to see if the application audio is disabled
 if($app.ColorDepth -ne "Colors32Bit"){
 $app_no32b+= "$app is not published in 32 bit.`n"
 }
 
 }
 
 echo "`nApps not 32bit: "
 echo $app_no32b
 
 
Write-Host "Press any key to continue …" 
$x = $host.UI.RawUI.ReadKey("NoEcho,IncludeKeyDown")

 


Change the green Workergroup to your workergroupname, it’s also possible to run this script without the parameter -WorkerGroup, but then all published content will be recognized as “non-32-bit”.

If you want see which application has audio disabled just change the attribut in the loop: 

---<snip>--- foreach($app in $applications)
{ #Check to see if the application audio is disabled if($app.AudioType -eq "none")
{ $app_noaudio+= "$app audio is currently disabled.`n" } } echo "`nApps Audio disabled: " echo $app_noaudio
---<snip>---

 

This easy loop you can recycle to check every application attribute, all possible attributes of an app you can get with an

Get-XAApplication -BrowserName "thebrowsernameofourapp"

Have a look into the StoreFront 2.x Subscription Database

Last days I had to deal with Citrix StoreFront 2.0 and found out that a numerous issues still exists and that some things are still not implemented to configure in the StoreFront MMC SnapIn.

Session timeouts and settings like enable or disable of features like workspace control still must be handled over the config-files. But this is all well documented the official documentation of Citrix.

But seems there is no possibility to have a look into the subscription database from Citrix Storefront which is now with version 2.0 in a proprietary non-MSSQL format. For this reason I created this small script (execute it on the StoreFront server):

#========================================================================
# Created on: 22.10.2013
# Created by: Sacha T. blog.sachathomet.ch
# Filename: GetSubscriptedStoreFrontApps.ps1
#========================================================================
#define some variables
#$domainname = "anotherDomain" # use that if your user is in another domain
$domainname = $env:userdomain
$storename = "StoreFront"      # Change this to your Store-Name
$subinfofile = "C:\temp\temp-subscriptions.csv"
Write-Host Query StoreFront apps in domain $domainname in Store $storename
$username = Read-Host "Please enter username to query"
#Add Module for Citrix StoreFront
Import-Module "C:\Program Files\Citrix\Receiver StoreFront\Scripts\ImportModules.ps1"
#Change username to domain SID
$objUser = New-Object System.Security.Principal.NTAccount($domainname, $username)
$strSID = $objUser.Translate([System.Security.Principal.SecurityIdentifier])
#delete old Subcriptionexportfile
Remove-Item $subinfofile -ErrorAction SilentlyContinue
#Create new Subcriptionexportfile
Export-DSStoreSubscriptions -StoreName $storename -FilePath $subinfofile
##Add a caption to the file, this is needed to process csv
$content = Get-Content $subinfofile
Set-Content $subinfofile sid.app
Add-Content $subinfofile $content
#Read all Lines in CSV from this User which are not unsubscribed
import-csv C:\Temp\temp-subscriptions.csv -delimiter "."| Where-Object {$_.sid -like "$strSID*" -and $_.app -notlike "*unsubscribed*"}| Format-Table -Property app
#wait to read the result - usefull if started from WindowsExplorer with "Run in PowerShell"
Write-Host "Press any key to continue …"
$x = $host.UI.RawUI.ReadKey("NoEcho,IncludeKeyDown")

 

When I’ve created this script I found out that deleted apps wont be removed from the subscription database and as well users who leave the company will still have records in the database after they are deleted in the AD. So within the years, the subscription database will have a lot of orphan data in the database. Seems that an automated clean-up does not exists.

There is a way to delete the records, have a look to forum post of Duncan Gabriel Thread:

Delete user subscriptions?  http://forums.citrix.com/thread.jspa?threadID=334609