Retrieve ID of current (local) TeamViewer host client

Options

Making a powershell script that installs, sets up easy access, and then automatically begins to install MWB. I have it working right now except I'm not sure yet where I can automatically fetch the ID of the local installation. Where do I find this value? I don't care if it's via the API or registry or somewhere else as long as it's accurate and I can pass the variable to the API.

$token = "token"

$headers = @{

  "Authorization" = "Bearer $token"

}


$postParams = @{

  "teamviewer_id" = $variableGoesHere

} | ConvertTo-Json


Invoke-WebRequest -Uri https://webapi.teamviewer.com/api/v1/endpointprotectionv2/install -Method POST -Headers $headers -Body $postParams -ContentType "application/json"

This is just the part of the script that handles the MWB installation, obviously. Not seeing anywhere obvious in the API documentation or registry that stores the local TV ID, but my knowledge of APIs is quite literally zero and it's 110% possibly I'm just not seeing it.

Comments

  • SamGW
    SamGW Posts: 3 ✭✭
    edited October 2023
    Options

    $response = Invoke-WebRequest -Uri https://webapi.teamviewer.com/api/v1/devices?parameters.name=$env:COMPUTER `

                     -Method GET -Headers $headers -ContentType "application/json"


    This is telling me that the 'required property teamviewer_id not found in json, so I guess name doesn't refer to alias? I can get the entire list of devices to dump out, but at that point I'd need to sift through it to not only find the one that matches the local computer, but then find the associated string of numbers that go with it. Seems like overengineering to what I'm sure a simpler solution exists?

    I'm more or less here right now, but this is returning the entire list of devices, not a singular one. Not sure how I need to be parsing this properly, or if it's even possible and I should instead just take the entire list and find a way to regex the associated TV ID.

  • SamGW
    SamGW Posts: 3 ✭✭
    Options

    Apparently I'm stupid and you can query the registry in HKLM\Software\TeamViewer or WoW6432Node\TeamViewer and ClientID or ClientID_64 contains the TeamViewer ID. You just need to convert from hexadecimal to decimal from there.