Works with TeamViewer QS and TeamViewer Full Version -
First setup registry scanning on the following keys for the RegValue of "ClientID":
HKEY_LOCAL_MACHINE\SOFTWARE\TeamViewer
HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\TeamViewer
HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\TeamViewer\Version6
HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\TeamViewer\Version7
HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\TeamViewer\Version8
HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\TeamViewer\Version9
HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\TeamViewer\Version10
HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\TeamViewer\Version11
HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\TeamViewer\Version12
Then instead of using the CSV method described above, I just query the database directly in powershell and use this asset action in lansweeper:
powershell -noprofile -executionpolicy bypass -command {actionpath}TV.ps1 {assetid}
I just have it scan my registry for the TV client IDs and then my TV.ps1 script in the Actions folder looks like this:
# lansweeper db connection details
$mssql_server_instance = "YOUR_DETAILS_HERE"
$mssql_databasename = "YOUR_DETAILS_HERE"
$ms_uid = "YOUR_DETAILS_HERE"
$ms_pwd = "YOUR_DETAILS_HERE"
function GetTeamViewerClientID {
param(
[Parameter(Mandatory = $true)][String] $ms_uid,
[Parameter(Mandatory = $true)][String] $ms_pwd,
[Parameter(Mandatory = $true)][String] $mssql_server_instance,
[Parameter(Mandatory = $true)][String] $mssql_databasename,
[Parameter(Mandatory = $true)][String] $LS_AssetID
)
$dbquery = "SELECT Value FROM lansweeperdb.dbo.tblRegistry WHERE AssetID='"+$LS_AssetID+"' AND Valuename = 'ClientID'"
$connectionString = 'Data Source={0};database={1};User ID={2};Password={3}' -f $mssql_server_instance,$mssql_databasename,$ms_uid,$ms_pwd
$connection = New-Object System.Data.SqlClient.SqlConnection $connectionString
$connection.ConnectionString = $connectionString
$command = New-Object System.Data.SqlClient.SqlCommand
$command.CommandText = $dbquery
$command.Connection = $connection
$SqlAdapter = New-Object System.Data.SqlClient.SqlDataAdapter
$SqlAdapter.SelectCommand = $command
$DataSet = New-Object System.Data.DataSet
$EXECUTE_QUERY = $SqlAdapter.Fill($DataSet)
$connection.Close()
foreach ($Row in $DataSet.Tables[0].Rows)
{
$tv_clientid = $Row.Value
}
return $tv_clientid
}
$LS_AssetID = $args[0]
$ARG = GetTeamViewerClientID $ms_uid $ms_pwd $mssql_server_instance $mssql_databasename $LS_AssetID
start-process -filepath "C:\Program Files\TeamViewer\TeamViewer.exe" -argumentlist "-i $ARG"
Be sure to edit the TV.ps1 script with your own lansweeper database connection details.