A while ago I was working on a very very old VMware View environment. Yes, you’ve read this correctly, a VMware View environment. This is even from before the product was officially called “VMware Horizon View” back in 2015.

So, the subject I was working on for the customer, but also for us since we manage it, was that we needed to know who got what session at what time of the day, and how many users logged in daily. This information would also be used for troubleshooting, since the environment wasn’t that up to date anymore, as you can probably imagine.

So, how did we tackle this? Well the VMware View Administrator console was not really up for the task, since you can only check “Current” or “Highest” number of sessions, but nothing with names, timestamps or anything like that.

VMware View Administrator console

What else can we use to get this information? Well, the only thing that I actually found that worked with this ancient environment were my trusted good ol’ PowerCLI modules! The VMware View PowerCLI plugin (VMware.View.Broker) for that matter. These are HARD to find for this old environment! I actually couldn’t find any downloads anymore at all, anywhere! Luckily the plugin was still inside the installation folder on the VMware View Connection Server. I did manage to save the add-snapin.ps1 and uninstall-snapin.ps1 files for this module. But if you don’t have the installation files that include the “.dll’s” you need, you don’t have any use for this (if you do want these, just let me know!).

Let’s suppose you have the View PowerCLI modules installed, like me, how do we get the information we need? Well let’s first have a look at the commands we have available in the plugin. You can do this by executing the following piece of code:

Get-Command | ?{$_.PSSnapin.name -eq "VMware.View.Broker"} CommandType Name Definition ----------- ---- ---------- Cmdlet Add-AutomaticLinkedClonePool Add-AutomaticLinkedClonePool... Cmdlet Add-AutomaticPool Add-AutomaticPool [-Pool_id ... Cmdlet Add-ManualPool Add-ManualPool [-Pool_id <St... Cmdlet Add-ManualUnmanagedPool Add-ManualUnmanagedPool [-Po... Cmdlet Add-PoolEntitlement Add-PoolEntitlement [-Pool_i... Cmdlet Add-TerminalServerPool Add-TerminalServerPool [-Poo... Cmdlet Add-TransferServer Add-TransferServer [-Vc_id <... Cmdlet Add-ViewVC Add-ViewVC [-ServerName <Str... Cmdlet Export-NetworkLabelSpecForFu... Export-NetworkLabelSpecForFu... Cmdlet Export-NetworkLabelSpecForLi... Export-NetworkLabelSpecForLi... Cmdlet Get-ComposerDomain Get-ComposerDomain [-Vc_id <... Cmdlet Get-ConnectionBroker Get-ConnectionBroker [[-Brok... Cmdlet Get-DesktopPhysicalMachine Get-DesktopPhysicalMachine [... Cmdlet Get-DesktopVM Get-DesktopVM [-Vc_id <Strin... Cmdlet Get-EventReport Get-EventReport [-ViewName <... Cmdlet Get-EventReportList Get-EventReportList [-Verbos... Cmdlet Get-GlobalSetting Get-GlobalSetting [-Verbose]... Cmdlet Get-License Get-License [-Verbose] [-Deb... Cmdlet Get-LocalSession Get-LocalSession [-Pool_id <... Cmdlet Get-Monitor Get-Monitor [-Monitor <Strin... Cmdlet Get-Pool Get-Pool [-Pool_id <String[]... Cmdlet Get-PoolEntitlement Get-PoolEntitlement [[-Pool_... Cmdlet Get-ProfileDisk Get-ProfileDisk [-Name <Stri... Cmdlet Get-RemoteSession Get-RemoteSession [-Username... Cmdlet Get-TerminalServer Get-TerminalServer [-Display... Cmdlet Get-TransferPackage Get-TransferPackage [-Packag... Cmdlet Get-TransferServer Get-TransferServer [-Path <S... Cmdlet Get-TransferServerState Get-TransferServerState [-Ts... Cmdlet Get-User Get-User [-IncludeUser] [-In... Cmdlet Get-ViewVC Get-ViewVC [-DisplayName <St... Cmdlet New-TransferPackage New-TransferPackage [-Vc_id ... Cmdlet Remove-Pool Remove-Pool [-Pool_id <Strin... Cmdlet Remove-PoolEntitlement Remove-PoolEntitlement [-Poo... Cmdlet Remove-TransferPackage Remove-TransferPackage [[-Pa... Cmdlet Remove-TransferServer Remove-TransferServer [[-Ts_... Cmdlet Remove-UserOwnership Remove-UserOwnership [[-Mach... Cmdlet Remove-ViewVC Remove-ViewVC [-Vc_id <Strin... Cmdlet Send-LinkedCloneRebalance Send-LinkedCloneRebalance [-... Cmdlet Send-LinkedCloneRecompose Send-LinkedCloneRecompose [-... Cmdlet Send-LinkedCloneRefresh Send-LinkedCloneRefresh [-Ma... Cmdlet Send-LocalSessionRollback Send-LocalSessionRollback [-... Cmdlet Send-SessionDisconnect Send-SessionDisconnect [[-Se... Cmdlet Send-SessionLogoff Send-SessionLogoff [[-Sessio... Cmdlet Send-VMReset Send-VMReset [-Machine_id <S... Cmdlet Set-ImageRepository Set-ImageRepository [-Local_... Cmdlet Set-License Set-License [-Key <String>] ... Cmdlet Set-TransferServerMaintMode Set-TransferServerMaintMode ... Cmdlet Update-AutomaticLinkedClonePool Update-AutomaticLinkedCloneP... Cmdlet Update-AutomaticPool Update-AutomaticPool [-Pool_... Cmdlet Update-ConnectionBroker Update-ConnectionBroker [-Br... Cmdlet Update-GlobalSetting Update-GlobalSetting [-Sessi... Cmdlet Update-ManualPool Update-ManualPool [-Pool_id ... Cmdlet Update-ManualUnmanagedPool Update-ManualUnmanagedPool [... Cmdlet Update-TerminalServerPool Update-TerminalServerPool [-... Cmdlet Update-UserOwnership Update-UserOwnership [-Machi... Cmdlet Update-ViewVC Update-ViewVC [-Vc_id <Strin... 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 Get-Command | ? { $_ . PSSnapin . name -eq "VMware.View.Broker" } CommandType Name Definition -- -- -- -- -- - -- -- -- -- -- -- -- Cmdlet Add-AutomaticLinkedClonePool Add-AutomaticLinkedClonePool . . . Cmdlet Add-AutomaticPool Add-AutomaticPool & #91;-Pool_id ... Cmdlet Add-ManualPool Add-ManualPool & #91;-Pool_id <St... Cmdlet Add-ManualUnmanagedPool Add-ManualUnmanagedPool & #91;-Po... Cmdlet Add-PoolEntitlement Add-PoolEntitlement & #91;-Pool_i... Cmdlet Add-TerminalServerPool Add-TerminalServerPool & #91;-Poo... Cmdlet Add-TransferServer Add-TransferServer & #91;-Vc_id <... Cmdlet Add-ViewVC Add-ViewVC & #91;-ServerName <Str... Cmdlet Export-NetworkLabelSpecForFu . . . Export-NetworkLabelSpecForFu . . . Cmdlet Export-NetworkLabelSpecForLi . . . Export-NetworkLabelSpecForLi . . . Cmdlet Get-ComposerDomain Get-ComposerDomain & #91;-Vc_id <... Cmdlet Get-ConnectionBroker Get-ConnectionBroker & #91;[-Brok... Cmdlet Get-DesktopPhysicalMachine Get-DesktopPhysicalMachine & #91;... Cmdlet Get-DesktopVM Get-DesktopVM & #91;-Vc_id <Strin... Cmdlet Get-EventReport Get-EventReport & #91;-ViewName <... Cmdlet Get-EventReportList Get-EventReportList & #91;-Verbos... Cmdlet Get-GlobalSetting Get-GlobalSetting & #91;-Verbose]... Cmdlet Get-License Get-License & #91;-Verbose] [-Deb... Cmdlet Get-LocalSession Get-LocalSession & #91;-Pool_id <... Cmdlet Get-Monitor Get-Monitor & #91;-Monitor <Strin... Cmdlet Get-Pool Get-Pool & #91;-Pool_id <String[]... Cmdlet Get-PoolEntitlement Get-PoolEntitlement & #91;[-Pool_... Cmdlet Get-ProfileDisk Get-ProfileDisk & #91;-Name <Stri... Cmdlet Get-RemoteSession Get-RemoteSession & #91;-Username... Cmdlet Get-TerminalServer Get-TerminalServer & #91;-Display... Cmdlet Get-TransferPackage Get-TransferPackage & #91;-Packag... Cmdlet Get-TransferServer Get-TransferServer & #91;-Path <S... Cmdlet Get-TransferServerState Get-TransferServerState & #91;-Ts... Cmdlet Get-User Get-User & #91;-IncludeUser] [-In... Cmdlet Get-ViewVC Get-ViewVC & #91;-DisplayName <St... Cmdlet New-TransferPackage New-TransferPackage & #91;-Vc_id ... Cmdlet Remove-Pool Remove-Pool & #91;-Pool_id <Strin... Cmdlet Remove-PoolEntitlement Remove-PoolEntitlement & #91;-Poo... Cmdlet Remove-TransferPackage Remove-TransferPackage & #91;[-Pa... Cmdlet Remove-TransferServer Remove-TransferServer & #91;[-Ts_... Cmdlet Remove-UserOwnership Remove-UserOwnership & #91;[-Mach... Cmdlet Remove-ViewVC Remove-ViewVC & #91;-Vc_id <Strin... Cmdlet Send-LinkedCloneRebalance Send-LinkedCloneRebalance & #91;-... Cmdlet Send-LinkedCloneRecompose Send-LinkedCloneRecompose & #91;-... Cmdlet Send-LinkedCloneRefresh Send-LinkedCloneRefresh & #91;-Ma... Cmdlet Send-LocalSessionRollback Send-LocalSessionRollback & #91;-... Cmdlet Send-SessionDisconnect Send-SessionDisconnect & #91;[-Se... Cmdlet Send-SessionLogoff Send-SessionLogoff & #91;[-Sessio... Cmdlet Send-VMReset Send-VMReset & #91;-Machine_id <S... Cmdlet Set -ImageRepository Set -ImageRepository & #91;-Local_... Cmdlet Set -License Set -License & #91;-Key <String>] ... Cmdlet Set -TransferServerMaintMode Set -TransferServerMaintMode . . . Cmdlet Update-AutomaticLinkedClonePool Update-AutomaticLinkedCloneP . . . Cmdlet Update-AutomaticPool Update-AutomaticPool & #91;-Pool_... Cmdlet Update-ConnectionBroker Update-ConnectionBroker & #91;-Br... Cmdlet Update-GlobalSetting Update-GlobalSetting & #91;-Sessi... Cmdlet Update-ManualPool Update-ManualPool & #91;-Pool_id ... Cmdlet Update-ManualUnmanagedPool Update-ManualUnmanagedPool & #91;... Cmdlet Update-TerminalServerPool Update-TerminalServerPool & #91;-... Cmdlet Update-UserOwnership Update-UserOwnership & #91;-Machi... Cmdlet Update-ViewVC Update-ViewVC & #91;-Vc_id <Strin...

Alright awesome! So it turns out that a lot of this actually matched up with the Horizon View PowerCLI 7 cmdlet Reference! But, back to the task at hand. Turns out there is actually only one command that was useful for me.

Get-EventReport 1 Get-EventReport

The rest wasn’t that useful to use for this task. The “Get-EventReport” cmdlet can give you quit some information, if you know how to use it. Before we can use this command it is useful to see what the command can deliver, you can check this by executing:

Get-EventReportList report-name report-description ----------- ------------------ user_events User-initiated events. e.g.: login/log out of broker,launch desktop. user_auth_failures User authentication failures e.g.: bad passwords, locked out, access de... user_count_events Report on the maximum number of concurrent users logged in during the day config_changes What changes were made to View Manager configuration settings (example:... 1 2 3 4 5 6 7 8 Get-EventReportList report -name report -description -- -- -- -- -- - -- -- -- -- -- -- -- -- -- user_events User -initiated events . e . g . : login / log out of broker , launch desktop . user_auth_failures User authentication failures e . g . : bad passwords , locked out , access de . . . user_count_events Report on the maximum number of concurrent users logged in during the day config_changes What changes were made to View Manager configuration settings ( example : . . .

This tells us that we can get information from four categories. To get the same information that we can see in the VMware View Administrator console just execute the following piece of code:

Get-EventReport –ViewName user_count_events report-result : 85 eventid : 4588106 module : Broker eventtype : BROKER_DAILY_MAX_USERS time : 2020-02-13 23:55:02.077 source : com.vmware.vdi.broker.events.loggers.maxsessiontracking.MaxSessionTimerTask severity : INFO moduleandeventtext : Over the past 24 hours, the maximum number of users with concurrent desktop sessions was 30 usercount : 30 1 2 3 4 5 6 7 8 9 10 11 Get-EventReport – ViewName user_count_events report -result : 85 eventid : 4588106 module : Broker eventtype : BROKER_DAILY_MAX_USERS time : 2020 -02 -13 23 : 55 : 02 . 077 source : com . vmware . vdi . broker . events . loggers . maxsessiontracking . MaxSessionTimerTask severity : INFO moduleandeventtext : Over the past 24 hours , the maximum number of users with concurrent desktop sessions was 30 usercount : 30

Now the rest is easy, we will narrow this down to a specific number of days, because the rest isn’t needed for our use case. By doing this you will end up with the following piece of code:

Get-EventReport -ViewName user_count_events -startDate ((Get-Date).AddDays(-7)) | sort time | Select time, usercount time usercount ---- --------- 2020-02-07 23:55:02.077 35 2020-02-07 23:55:02.077 35 2020-02-08 23:55:01.273 35 2020-02-08 23:55:01.273 35 2020-02-09 23:55:01.3 35 2020-02-09 23:55:01.3 35 2020-02-10 23:55:02.08 30 2020-02-10 23:55:02.08 30 2020-02-11 23:55:01.27 39 2020-02-11 23:55:01.27 39 2020-02-12 23:55:01.3 36 2020-02-12 23:55:01.3 36 2020-02-13 23:55:02.077 30 2020-02-13 23:55:02.077 30 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 Get-EventReport -ViewName user_count_events -startDate ( ( Get-Date ) . AddDays ( -7 ) ) | sort time | Select time , usercount time usercount -- -- -- -- -- -- - 2020 -02 -07 23 : 55 : 02 . 077 35 2020 -02 -07 23 : 55 : 02 . 077 35 2020 -02 -08 23 : 55 : 01 . 273 35 2020 -02 -08 23 : 55 : 01 . 273 35 2020 -02 -09 23 : 55 : 01 . 3 35 2020 -02 -09 23 : 55 : 01 . 3 35 2020 -02 -10 23 : 55 : 02 . 08 30 2020 -02 -10 23 : 55 : 02 . 08 30 2020 -02 -11 23 : 55 : 01 . 27 39 2020 -02 -11 23 : 55 : 01 . 27 39 2020 -02 -12 23 : 55 : 01 . 3 36 2020 -02 -12 23 : 55 : 01 . 3 36 2020 -02 -13 23 : 55 : 02 . 077 30 2020 -02 -13 23 : 55 : 02 . 077 30

The next thing we wanted to know was what user logged in at what time. This was for troubleshooting purposes because the VMware View Administrator console isn’t the fastest to display events, especially the older version of View. We started looking at the same command again and used the “user_events” ViewName type category. This resulted in many events. To sort through these it’s useful to check what type of events there are:

Get-EventReport –ViewName user_events | Select EventType –Unique eventtype --------- BROKER_USERLOGGEDIN BROKER_USERLOGGEDOUT 1 2 3 4 5 6 Get-EventReport – ViewName user_events | Select EventType – Unique eventtype -- -- -- -- - BROKER_USERLOGGEDIN BROKER_USERLOGGEDOUT

Turns out, only two are available. This makes it easy to find out whether a user logged in succesfully or not. Just run the below command to find out when a user logged in.

Get-EventReport -ViewName user_events | ?{$_.EventType -eq "BROKER_USERLOGGEDIN" -AND $_.severity -eq "AUDIT_SUCCESS"} 1 Get-EventReport -ViewName user_events | ? { $_ . EventType -eq "BROKER_USERLOGGEDIN" -AND $_ . severity -eq "AUDIT_SUCCESS" }

So now that we have the information we need, we need to find a way to schedule this so that we can use this information, anytime we need it. Fortunately, scheduling PowerShell code is very easy. Just create a “.ps1” file and schedule it to run in Windows Task Manager. I ended up with the following script, which satisfied our needs.

#Start of script. ########################################## # Author = Bryan van Eeden # # Version = 1.0 # # Date = 01/02/2020 # ########################################## Add-PSSnapin VMware.View.Broker $date = get-date -uformat '%m-%d-%Y-%H%M' $filenamelocation = $("C:\temp\Loggedinusers_day" + $date + ".txt") Get-EventReport -ViewName user_events -startDate ((Get-Date).AddDays(-6)) | ?{$_.eventtype -eq "BROKER_USERLOGGEDIN" -AND $_.severity -eq "AUDIT_SUCCESS"} | sort time | Select time, userdisplayname -Unique >> $filenamelocation $filenamelocation2 = $("C:\temp\Concurrent_users" + $date + ".txt") Get-EventReport -ViewName user_count_events -startDate ((Get-Date).AddDays(-7)) | sort time | Select time, usercount >> $filenamelocation2 #End of script. 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 #Start of script. ########################################## # Author = Bryan van Eeden # # Version = 1.0 # # Date = 01/02/2020 # ########################################## Add-PSSnapin VMware . View . Broker $date = get-date -uformat '%m-%d-%Y-%H%M' $filenamelocation = $ ( "C:\temp\Loggedinusers_day" + $date + ".txt" ) Get-EventReport -ViewName user_events -startDate ( ( Get-Date ) . AddDays ( -6 ) ) | ? { $_ . eventtype -eq "BROKER_USERLOGGEDIN" -AND $_ . severity -eq "AUDIT_SUCCESS" } | sort time | Select time , userdisplayname -Unique >> $filenamelocation $filenamelocation2 = $ ( "C:\temp\Concurrent_users" + $date + ".txt" ) Get-EventReport -ViewName user_count_events -startDate ( ( Get-Date ) . AddDays ( -7 ) ) | sort time | Select time , usercount >> $filenamelocation2 #End of script.

Sample content of Loggedinusers_day_02-14-2020-0000.txt time userdisplayname ---- --------------- 2020-02-08 04:55:40.793 vcloudvision.com\user01 2020-02-08 08:57:09.933 vcloudvision.com\user01 2020-02-08 09:32:46.127 vcloudvision.com\user01 2020-02-08 09:34:11.737 vcloudvision.com\user01 2020-02-08 09:51:03.68 vcloudvision.com\user01 2020-02-08 09:51:57.667 vcloudvision.com\user02 2020-02-08 11:09:35.55 vcloudvision.com\user03 2020-02-08 11:28:35.917 vcloudvision.com\user04 2020-02-08 12:31:33.997 vcloudvision.com\user02 2020-02-08 13:09:38.157 vcloudvision.com\user02 2020-02-08 13:09:45.233 vcloudvision.com\user02 2020-02-08 13:29:29.833 vcloudvision.com\user02 2020-02-08 14:06:54.623 vcloudvision.com\user02 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 Sample content of Loggedinusers_day_02 -14 -2020 -0000 . txt time userdisplayname -- -- -- -- -- -- -- -- -- - 2020 -02 -08 04 : 55 : 40 . 793 vcloudvision . com \ user01 2020 -02 -08 08 : 57 : 09 . 933 vcloudvision . com \ user01 2020 -02 -08 09 : 32 : 46 . 127 vcloudvision . com \ user01 2020 -02 -08 09 : 34 : 11 . 737 vcloudvision . com \ user01 2020 -02 -08 09 : 51 : 03 . 68 vcloudvision . com \ user01 2020 -02 -08 09 : 51 : 57 . 667 vcloudvision . com \ user02 2020 -02 -08 11 : 09 : 35 . 55 vcloudvision . com \ user03 2020 -02 -08 11 : 28 : 35 . 917 vcloudvision . com \ user04 2020 -02 -08 12 : 31 : 33 . 997 vcloudvision . com \ user02 2020 -02 -08 13 : 09 : 38 . 157 vcloudvision . com \ user02 2020 -02 -08 13 : 09 : 45 . 233 vcloudvision . com \ user02 2020 -02 -08 13 : 29 : 29 . 833 vcloudvision . com \ user02 2020 -02 -08 14 : 06 : 54 . 623 vcloudvision . com \ user02

Sample content of Concurrent_users_02-14-2020-0000.txt time usercount ---- --------- 2020-02-07 23:55:02.077 35 2020-02-07 23:55:02.077 35 2020-02-08 23:55:01.273 35 2020-02-08 23:55:01.273 35 2020-02-09 23:55:01.3 35 2020-02-09 23:55:01.3 35 2020-02-10 23:55:02.08 30 2020-02-10 23:55:02.08 30 2020-02-11 23:55:01.27 39 2020-02-11 23:55:01.27 39 2020-02-12 23:55:01.3 36 2020-02-12 23:55:01.3 36 2020-02-13 23:55:02.077 30 2020-02-13 23:55:02.077 30 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 Sample content of Concurrent_users_02 -14 -2020 -0000 . txt time usercount -- -- -- -- -- -- - 2020 -02 -07 23 : 55 : 02 . 077 35 2020 -02 -07 23 : 55 : 02 . 077 35 2020 -02 -08 23 : 55 : 01 . 273 35 2020 -02 -08 23 : 55 : 01 . 273 35 2020 -02 -09 23 : 55 : 01 . 3 35 2020 -02 -09 23 : 55 : 01 . 3 35 2020 -02 -10 23 : 55 : 02 . 08 30 2020 -02 -10 23 : 55 : 02 . 08 30 2020 -02 -11 23 : 55 : 01 . 27 39 2020 -02 -11 23 : 55 : 01 . 27 39 2020 -02 -12 23 : 55 : 01 . 3 36 2020 -02 -12 23 : 55 : 01 . 3 36 2020 -02 -13 23 : 55 : 02 . 077 30 2020 -02 -13 23 : 55 : 02 . 077 30

So there you have it. Even the ancient VMware View environment I was working on had ways to find our information that the VMware View Administrator console didn’t have. Hope you found this post useful!