Powershell Script to Reduce Managed Devices Count and Avoid Extra TV Charges

Hi All,

As you may be aware Teamviewer have been contacting customers that have used more than their allocated "Managed" device allocations, and informing them of the good news that they will now be subject to additional yearly charges if they wish to continue using Managed Devices (aka "Easy Access") - I don't really use this feature and did not want to pay around an extra 4000 euro per year for the privilege.

They said if I wanted to reduce this count, that I could can log onto each endpoint one at a time, and disable Easy Access. How convenient!

In my case, I had an allocation of 1000, and a usage count of around 3500. There is no way I would be able to log onto 2500 computers and change the setting manually.

The other way around it would be to delete and and re-create each computer on the contact/contacts list - again - tedious to near impossible to do this manually.

So, I've come up with this novel approach through PowerShell which basically loops through all managed devices, deletes them, and re-creates them.

Small warning in advance, if you have any saved passwords on those contacts, they will be lost.

But, the good news is that after 24 hours, your quantity of "Managed Devices" will go down to 0, and you wont need to pay the extra fees.

-------

$token = Read-Host -Prompt "Paste your account token code here"

$bearer = "Bearer",$token

$header = New-Object "System.Collections.Generic.Dictionary[[String],[String]]"

$header.Add("authorization", $bearer)

## Get all Devices that are Managed / Assigned

$request = Invoke-RestMethod -Uri "https://webapi.teamviewer.com/api/v1/devices" -Method Get -Headers $header

$assigneddevices = $request.devices | where {$_.assigned_to -eq "True"}

$n=1

$assigneddevices | foreach-object {

$info = $n.tostring() + " - Processing... - (" + $_.alias + ") (" + $_.teamviewer_id + ")"

write-host $Info

## Delete Device

$uri = "https://webapi.teamviewer.com/api/v1/devices/" + $_.device_id

$request = Invoke-RestMethod -Uri $uri -Method Delete -Headers $header

## Add Device

$device=@{

"alias" = $_.alias

"groupid" = $_.groupid

"remotecontrol_id" = $_.remotecontrol_id

} | ConvertTo-Json

$uri = "https://webapi.teamviewer.com/api/v1/devices/"

$request = Invoke-RestMethod -Uri $uri -ContentType 'application/json' -Method POST -Headers $header -Body $device

$n += 1

}


Then wait until the count refreshes!

Hope this helps someone!

Denis

Comments

  • focuspic
    focuspic Posts: 1

    I'm in the same boat as you. Wanna try your script, which I don't have any experience. So opened up the script page in TeamViewer copy /pasted your script, gived a name, description, selected Windows, PowerShell, checked "Run as Administrator" clicked "save" and get 2 messages:

    -Couldn't create script "name"

    -Script "name" was successfully created

    But no script appears in the list? Is there something i'm doing wrong?


    Thanks in advance,

    François