I decided to create separate document with my own list of usefull powershell commands for XenApp 6.5. I will continously update this document with command examples I use in my current projects. Feel free to posts comments if you have better solution or command syntax.
Servers
# QFarm #List all servers in the XenApp farm QFarm /online #List all online servers QFarm /offline #List all offline servers QFarm /Zone EMEA /online #List online servers in EMEA zone #
#List disconnected sessions
Get-XASession |Select ServerName, State, AccountName, BrowserName |Where {$_.State -eq "Disconnected"} |Sort ServerName
#List sessions matching more than one condition
Get-XASession |Select ServerName, State, AccountName, BrowserName |Where {$_.BrowserName -notlike "Desktop" -and $_.State -eq "Disconnected"} |Sort ServerName
#
#List configured zones in the farm
Get-XAZone
#List load for all servers in the farm
Get-XAServerLoad
#List load for all servers in EMEA zone
Get-XAServer -ZoneName EMEA |Select ServerName |Get-XAServerLoad |Sort -Desc Load
#List all servers reporting problem with license server
Get-XAServer -ZoneName EMEA |Select ServerName |Get-XAServerLoad |where {$_.Load -eq 20000 }|Sort ServerName
#List load per server using WMI query
Get-WmiObject -Namespace root\citrix -Class MetaFrame_Server_LoadLevel |Select ServerName, LoadLevel
#
#
Get-Service |where {$_.Name -match "Citrix" -or $_.DisplayName -match "citrix" } |Sort Status |Format-Table -AutoSize
#
#List all counter sets
get-counter -listset *
get-counter -listset "citrix*"
#Available Citrix counter sets:
Citrix Licensing
Citrix CPU Utilization Mgmt User
Citrix IMA Networking
Citrix MetaFrame Presentation Server
ICA Session
#List all counter names in the ICA Session counter set
(get-counter -listset "ica session").counter
#List all counter names matching specified criteria
(get-counter -listset "ica session").counter |where {$_ -match "latency" }
#Display counter value for ICA session average latency
Get-Counter -Counter "\ICA Session(*)\Latency - Session Average"
or
$1=(get-counter -listset "ica session").counter |where {$_ -match "session average" }
Get-Counter -Counter $1
#
Users
#
#List all sessions with status different than Listening or Connected
Get-XASession |Select SessionId, AccountName, ServerName, State |Where {$_.State -ne "Listening" -and $_.State -ne "Connected"}
or
#List all session with status Active or Disconnected
Get-XASession |Select SessionId, AccountName, ServerName, State |Where {$_.State -eq "Active" -or $_.State -eq "Disconnected"}
#
#Count all active sesions
(Get-XASession |where {$_.State -eq "Active" }).count
#Count active session per server in particular zone
Get-XAServer -Zone EMEA |Get-XASession |Where {$_.State -eq "Active" }|Sort ServerName |Group-Object ServerName |Format-Table Name,Count -Auto
#Count all active sessions per particular server
Get-XASession -ServerName Server01 |Where {$_.State -eq "Active" }).Count
#
#Reset session
Stop-XASession -ServerName Server01 -SessionId 2
or
Get-XASession |where {$_.accountname -like "*UserABC"} |Stop-XASession
#Disconnect session
Disconnect-XASession -ServerName Server01 -SessionId 3 or Get-XASession |where {$_.accountname -like "*UserABC"} |Disconnect-XASession
#
#List all processes in particular session Get-XASessionProcess -ServerName Server01 -SessionId 2 |select ProcessName, ProcessId #Stop application running process 5304 Stop-XASessionProcess -ServerName xenufrdtc01 -ProcessId 5304 #
Applications
# Get-XAWorkerGroup *EMEA* |Select WorkerGroupName |Get-XAApplication |Select DisplayName,ClientFolder,ApplicationType |Out-File -Append c:\app-group.txt #
# Get-XAApplicationReport -BrowserName ApplicationABC |select Accounts #
#
Get-XASession |Select SessionId, State, BrowserName, AccountName, ServerName |Where {$_.AccountName -like "*UserABC*"}
#
#List all processes in particular session Get-XASessionProcess -ServerName Server01 -SessionId 2 |select ProcessName, ProcessId #Stop application running process 5304 Stop-XASessionProcess -ServerName xenufrdtc01 -ProcessId 5304 #
Printers
#List all drivers from Server01
Get-XAPrinterDriver -SourceServerName Server01 |Select DriverName |Sort DriverName
#List all drivers matching name HP*
Get-XAPrinterDriver -ServerName Server01 |Select DriverName |Where {$_.DriverName -like "HP*"} |Sort DriverName
Get-XAPrinterDriver -ServerName Server01 |Select DriverName |Where {$_.DriverName -like "HP*v6*"} |Sort DriverName
#
#List printer drivers in the Auto-Replication-List Get-XAAutoReplicatedPrinterDriver #Manual replication Start-XAPrinterDriverReplication "HP Universal Printing PCL 6 (v6.0.0)" -ServerName Server02,Server03 #Auto replication Add-XAAutoReplicatedPrinterDriver -ServerName Server01 "HP Universal Printing PCL 6 (v6.0.0)" #
To be continued ….
I was so excited when I found this page that I lost control of my bowels and shit myself. Several times, in fact. Why can’t Citrix post a page like this? You’ve made it so easy! Thanks!
Hi, i was using the script for listing connected users with powershell(x86).
Then i get the errror as below, am i doing it wrongly?
The term ‘Get-XASession’ is not recognized as the name of a cmdlet, function, script file, or operable program. Check t
he spelling of the name, or if a path was included, verify that the path is correct and try again.
At line:1 char:14
+ Get-XASession <<<< | Select SessionId, AccountName, ServerName, State | Where {$_.State -ne "Listening" -and $_.Stat
e -ne "Connected"}
+ CategoryInfo : ObjectNotFound: (Get-XASession:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
i got it sorted out, i just need to add this line before executing the script
add-pssnapin Citrix.* -erroraction silentlycontinue
Hi,
I’m pretty new to Powershell, but i would need a script that asks for a username, then checks if he is connected in the xenapp farm and show me, if he is active right now (or when his last action was in minutes:seconds). is there a way to do that?
These are absolutely great! Any chance you could throw together a quick query that compiles all sessions that have a hostname like “hostname*” so I can see a total of users connected (or not connected) that conform to a hostname standard?
Hi, how to get the list of plugins in IE8 through powershell in a server
Hi I have a critical requirement. I wanted to be alerted if a specific user gets disconnected an in case of high latency in his session.
Could you please help me with the script? I think below logic helps to furnish my requirement, but I am new to powershell, so that will be really great if you can help on this:
Overall I need a constantly running task that will:
1) Poll each XenApp farms
2) Find specific user connections
3) Compare state
4) if status change, send alert
Excellent Blog !
Its very informative for me .
I really enjoyed reading this post .
Excellent Blog