Here are some useful queries, noting that most begin with Get-Broker. To see what cmdlets are available, you can run this
Pipe the above through Out-GridView
) to see in a handy, filterable and sortable, table.
Alternatively, enter Get-Broker and either hit the tab key to cycle through the list of commands or hit ctrl+space to bring a cursor selectable list up on screen as seen in Figure 2.
Fig. 2: Get-Broker brings up a cursor selectable list of all available cmdlets
You can also use the Get-Help cmdlet on them, with optional -ShowWindow or -OnLine parameters, to get more detail and to see examples of their usage.
Q1. How many sessions are there in total, including connected and disconnected?
Get-BrokerSession -AdminAddress $ddc -MaxRecordCount 10000 | measure | select count
Q2. What is the breakdown of active versus disconnected sessions?
Get-BrokerSession @commonCVADparameters | Group-Object -Property SessionState
Fig. 3: Output of the Command described above
The “Connected” state is where there is a logon in progress.
Q3. What connected sessions have been idle for more than 30 minutes?
$activeSessions = Get-BrokerSession @commonCVADparameters -SessionState Active
$activeSessions|where IdleDuration -gt "00:30:00"|select machinename,username,client*,starttime,idle* | Out-GridView
Note that here we get all active sessions, as in not disconnected
, and store them in a variable. This way, we can perform analysis of this data without having to fetch it repeatedly, although the downside is that the data does not auto refresh.
Also note, that we filter in the cmdlet itself (-SessionState), where possible, rather than piping through Where-Object (alias where or ?) as that is faster because using Where-Object retrieves the entire result set and then filters it (figure 4).
Fig. 4: With the command described above, you receive a list of all active sessions
Q4. When and where did user billybob logon?
Get-BrokerSession -UserName guyrleechbillybob @commonCVADparameters | select machinename,client*,DesktopGroupName,CatalogName,starttime
Fig. 5: With the command described above you can retrieve information about the last login of a certain user
Q5. How many machines are registered and not in maintenance mode per delivery group?
Get-BrokerMachine -InMaintenanceMode $false -RegistrationState Registered @commonCVADparameters | group DesktopGroupName|select count,name|sort count
Fig. 6: List of all CVAD machines that are registered and not in maintenance mode, sorted by delivery group
Q6. Which machines have the most user sessions, e.g., do we have an overloaded machine or is load balancing work ok?
Get-BrokerMachine @commonCVADparameters | Sort SessionCount -Descending|select -first 10 machinename, sessioncount, DesktopGroupName, last*|Out-GridView
Fig. 7: A list of the machines that have the most user sessions, displayed in Citrix Studio
Q7. Show Delivery Group Statistics
Get-BrokerDesktopGroup | select Name,Desktop*,Enabled,InMaintenanceMode,Total*|ogv -PassThru
Fig. 8: Delivery group statistics in Citrix Studio
Note the use of -PassThru to Out-GridView so the selected items in the grid view – when “OK” is pressed – will be made available where the cmdlet was called from.
Alternatively, they can be piped through Set-ClipBoard (alias scb) so that the data can be pasted into Notepad, an email, OneNote, change control notes, etc.
Fig. 9: You can paste the data into notepad via Set-ClipBoard