Export VMware Horizon Sessions to CSV

Export VMware Horizon Sessions to CSV

Horizon-Sessions

Export VMware Horizon Session Data into .CSV

This script will export Horizon Session data into a .CSV file in My Documents Folder.

There is no support for this tool - it is provided as-is

Please provide any feedback directly to me - my contact information:

Chris Halstead - Staff Architect, VMware
Email: chalstead@vmware.com
Twitter: @chrisdhalstead

Thanks to Wouter Kursten for the feedback on supporting over 1,000 sessions.

The code to support that is based off of his post here: https://www.retouw.nl/2017/12/12/get-hvmachine-only-finds-1000-desktops/

This script requires Horizon 7 PowerCLI - https://blogs.vmware.com/euc/2020/01/vmware-horizon-7-powercli.html

Updated January 22, 2021

Update to support over 1,000 Horizon Sessions


Script Overview

This is a PowerShell script that uses PowerCLI and the View-API to query Horizon sessions. The session are written to a table in the script and also to a .CSV file that can be opened in Excel or a similar spreadsheet tool.

  • The .csv file is written to the My Documents folder of the user running the script. The file format is: Sessions_Month_Date_Year.csv

Script Usage

Run Horizon - Sessions.ps1

Menu

Login to Horizon Connection Server

Choose 1 to Login to a Horizon Connection Server

  • Enter the FQDN of the server when prompted to "Enter the Horizon Server Name" hit enter

  • Enter the Username of an account with Administrative access to the Horizon Server you are connecting to when prompted to "Enter the Username" hit enter

  • Enter that users Password and click enter

  • Enter that users Domain and click enter

    You will see that you are now logged in to Horizon - click enter to go back to the menu

    Login

Return Horizon Sessions

Choose 2 to return Horizon Sessions. They will be written to a table and also to a .CSV file in My Documents.

Sessions

Note that the location of the .CSV file will be written out after the script executes.


Sign in to be able to add comments.

Comments 3


1509659204 2 years ago
Very nice work!

We added these in order to give use the Session Start Time:
Add Content Path: "Session Start Time",
Results Format-Table and Results Select-Object: @{Name = 'Session Start Time'; Expression = {$_.sessiondata.startTime}},

Now, we just need it to be able to return 3,000+ sessions. We look forward to the updated version. Thank you!
chalstead 2 years ago
Good one - thanks! I will get that added to the default list of output and will try to get the sessions over 1000 piece fixed today. thanks!!
chalstead 2 years ago
The version up there is now able to return over 1,000 sessions, I also added session start time - please test it out and let me know. Thanks!