I had some messages about getting the latest TeamViewer ID’s, so here is an updated Powershell script that should return all versions.

$TeamViewerVersions = @('6','7','8','9','')

If([IntPtr]::Size -eq 4) {
    $RegPath='HKLM:\SOFTWARE\TeamViewer'    
} else {
    $RegPath='HKLM:\SOFTWARE\Wow6432Node\TeamViewer'
}

$ErrorActionPreference= 'silentlycontinue'

foreach ($TeamViewerVersion in $TeamViewerVersions) {
    If ((Get-Item -Path $RegPath$TeamViewerVersion).GetValue('ClientID') -ne $null) {
        $TeamViewerID=(Get-Item -Path $RegPath$TeamViewerVersion).GetValue('ClientID')
    }
}

Write-Host "The Teamviewer ID of $ENV:COMPUTERNAME is '$TeamViewerID'"