VMware View Get-ThinClient device name with Powershell

Last week our Desktop Team asked me question how we can get information about which ThinClient user is login from. Sounds like good idea for script or function.

After research I found that View Agent writing some information to Windows Registry which include info about ThinClient device as Name, IP Address, Connection Server and so on. This information are written under HKCU\Volatile Environment and HKU\User SID\Volatile Environment, my function retrieving information from the second one. First to be able to read Registry key we need to start Remote Registry service. Next using reg query command I read Registry entry under HKEY_Users to look fo SID of logon user. Next it reads Voltaire Environment and look for key with value ViewClient_Machine_Name which contain data with ThinClient name from which user is login.

I have created simple function to retrieve ThinClient name and print it to screen:

        A brief description of the Get-ThinClient function.
        Function to retrieve information about Thinclient name from which user login to Horizon View VDI

        A description of the file.
    .PARAMETER Computer
        A description of the Computer parameter.
        Use full Horizon View VDI Computer name. 
        PS C:\> Get-ThinClient -Computer 'Value1'

        Tky2  Sebastian Two logon from EXAMWIN08
        Created with:   SAPIEN Technologies, Inc., PowerShell Studio 2016 v5.2.123
        Created on:     8/8/2016 11:34 AM
        Created by:     Sebastian
Function Get-ThinClient
    Param (
    Foreach($VDI in $Computer){
        Get-Service -ComputerName $VDI RemoteRegistry | Start-Service
        $RegUser = reg query "\\$VDI\hku"
        $Key = ($RegUser.get(4)).replace('HKEY_USERS\', '')
        if ($Key.Length -ge 9)
            $RegInfo = reg query "\\$VDI\HKU\$Key\Volatile Environment"
            $UN = $RegInfo -cmatch "USERNAME"
            $UserName = $UN.Replace("   USERNAME    REG_SZ    ","")
            $tc = $RegInfo -cmatch "ViewClient_Machine_Name"
            $ThinClient = $tc.replace("    ViewClient_Machine_Name    REG_SZ    ","")
            Write-Output "$UserName logon from $ThinClient to VDI $VDI"
            Write-Output "$VDI no user Logon" 
} # Function End

Hope someone will find this helpful, my Desktop team did.


3 responses to “VMware View Get-ThinClient device name with Powershell

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.