-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathHorizonEventsQuery.ps1
More file actions
30 lines (23 loc) · 1.21 KB
/
Copy pathHorizonEventsQuery.ps1
File metadata and controls
30 lines (23 loc) · 1.21 KB
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
# The purpose of this script is to provide a quick way to search the VMware Horizon event log for
# a specific user's activity and present it in a table sorted newest first.
# The logged in user must have read rights to the Horizon Events database.
# Written by Rick R, last updated 28 Apr 2022
# Username to search for is required
param(
[Parameter(Mandatory)]
[string]$userName
)
# Modify these properties for your environment
[string] $Server= "MYSQLSERVER\INSTANCE" # Your SQL Server computername and SQL instance name
[string] $Database = "HorizonEvents" # Your VMware Horizon Events database name
# SQL Query
[string] $UserSqlQuery= "select * from dbo.event where ModuleAndEventText like '%$userName%'"
# SQLServer module must be installed to work
if (!(Get-Module -Name SqlServer)) {
Write-Host "You must add the SQL Server Powershell module from PSGallery to run this script"
Exit
}
# Query the database ...
$results = Invoke-SqlCmd -ServerInstance $Server -Database $Database -Query $UserSqlQuery
# ...and display the data in a table. You could optionally pipe this to a file.
$results | Sort-Object -Descending Time | Select-Object EventType, ModuleAndEventText, Time