Skip to content

Instantly share code, notes, and snippets.

@VertigoRay
Last active November 15, 2023 01:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save VertigoRay/6b78dbf5ce7d9c4edcea1a1d057b0714 to your computer and use it in GitHub Desktop.
Save VertigoRay/6b78dbf5ce7d9c4edcea1a1d057b0714 to your computer and use it in GitHub Desktop.
Test Horizon Connections

Use these scripts to test VMware Horizon client connections. The idea with these simple scripts is that a user might be telling IT staff that "they can't connect" or "it's not working." These are simple scripts that can be run to collect useful information into a TestHorizonConnections.*.log file for sending to the IT staff.

The log file will get automatically created in the users Downloads folder. the * is a timestamp. The file will be named something like this:

  • TestHorizonConnections.2023-11-06T12_19_46.5917880-06_00.log

Windows

Run this command from PowerShell:

iwr https://shorturl.at/oyEJZ -useb | iex

Number of URL clicks.

MacOS

Run this command from Terminal:

curl -fsSL https://shorturl.at/axz15 | /bin/zsh

Number of URL clicks.

# README: https://gist.github.com/VertigoRay/6b78dbf5ce7d9c4edcea1a1d057b0714
Start-Transcript "${env:UserProfile}\Downloads\TestHorizonConnections.$((Get-Date -Format 'O').Replace(':', '_')).log" -IncludeInvocationHeader
Write-Output '#########################################'
Write-Output '# IP Info'
Write-Output '#########################################'
Invoke-RestMethod 'https://ipinfo.io/json'
Write-Output '#########################################'
Write-Output '# VMware Horizon View Client: Prefs'
Write-Output '#########################################'
$prefs = Get-Content "${env:APPDATA}\VMware\VMware Horizon View Client\prefs.txt"
Write-Output $prefs
Write-Output '#########################################'
Write-Output '# Testing Network Connections'
Write-Output '#########################################'
foreach ($recentServer in ([xml] $prefs).Root.RecentServer) {
Test-NetConnection $recentServer.ServerName -Port 443
foreach ($secondaryServer in $recentServer.SecondaryServerList.SecondaryServer.name) {
[uri] $serverUri = $secondaryServer
Test-NetConnection $serverUri.Host -Port $serverUri.Port
}
}
Stop-Transcript
#!/bin/zsh
# README: https://gist.github.com/VertigoRay/6b78dbf5ce7d9c4edcea1a1d057b0714
log="$HOME/Downloads/TestHorizonConnections.$(date +%FT%k_%m_%s%z).log"
echo "Logging to: $log"
exec 3>&1 1>$log 2>&1
#set -x
echo '#########################################'
echo '# IP Info'
echo '#########################################'
curl -fsSL ipinfo.io/json
echo
echo '#########################################'
echo '# IP Config'
echo '#########################################'
ifconfig | grep "inet "
echo
echo '#########################################'
echo '# VMware Horizon View Client: Prefs'
echo '#########################################'
defaults read com.vmware.horizon
echo
echo '##################################################'
echo '# Testing Network Connections: Brokers'
echo '##################################################'
brokerHistory=$(defaults read com.vmware.horizon broker-history)
foreach broker in $(echo $brokerHistory); do
#RegEx:https://regex101.com/r/bkh6jR/1
if [[ $broker =~ 'https://([^:]+):([0-9]+)/' ]]; then
nc -vz ${match[1]} ${match[2]}
fi
done
echo
echo '##################################################'
echo '# Testing Network Connections: Trusted Servers'
echo '##################################################'
trustedServers=$(defaults read com.vmware.horizon trustedServers)
foreach trusted in $(echo $trustedServers); do
#RegEx:https://regex101.com/r/bkh6jR/1
if [[ $trusted =~ 'https://([^:]+):([0-9]+)/' ]]; then
nc -vz ${match[1]} ${match[2]}
fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment