[Last Reviewed: 2018-11-19]
Recently one of our technicians mentioned in passing how nice it would be if TeamViewer’s console showed usernames in addition to computer names, so searching would be easier.
That’s a fantastic idea–let’s use the TeamViewer API and ConfigMgr’s User Affinity to do this!
Prerequisites: Tokens, Please
Before we begin, we’ll need a script token from TeamViewer. Once you’ve generated this token, don’t share it with anyone! It’s essentially your password to make changes to your TeamViewer account, so keep it close.
(Also: if possible, try to use just one token for each application you create. In this case, use this token only for this script. It’s easy enough to generate new tokens, and it let’s you be a bit more granular with permissions.)
To create a token, log in to your TeamViewer web console, then click on your name at the top right and select Edit Profile. Click Apps. Now click Create script token.
Give it a nice name (like Update-TeamViewerAlias
) and a description. The access level should be set to User. The only drop-down we need to change is Computers & Contacts — change this to View, add, edit and delete entries.
Click Save. Make a note of that token!
The ConfigMgr Magic
Now create a Configuration Item in ConfigMgr. The full Discovery and Remediation scripts are available on GitHub. Paste your token in line 2 of each of these scripts (replacing YOUR-TEAM-VIEWER-API-KEY
)
The Discovery script performs the following steps:
- Uses TeamViewer’s ping API to make sure the service is available
- Checks to see if the computer the script is running on has the username in it’s TeamViewer alias
For our compliance condition, we want the value of the script to return “true” (and run the remediation script if needed)
The Remediation script performs the following steps:
- Uses TeamViewer’s ping API to make sure the service is available
- Downloads the list of all TeamViewer computers, then uses the Remote Control ID (which is local) to learn the Device ID (which is not local)
- Grabs ConfigMgr’s user device affinity information for the machine
- Uses TeamViewer’s device API to update the alias (and update the description with the current date).
The Finale
Deploy this baseline to your TeamViewer machines (I use a schedule of once per week, but you can season to taste).
Before, with just the computer name
And after–now you can search for computers with a username!
Want to add more lines in the Description field? Just use `n
to separate lines:
description = "Automated for Awesome with PowerShell`nLast Updated: $(Get-Date -UFormat %Y-%m-%d)"
When adding details to the Description field, just take note that you can’t searchagainst that field.
Now all your technicians need to assist your customers is a username–a win for everyone!