This script will attempt to lock down the TeamViewer settings by creating an options password for TeamViewer Host installations. In turn, users will be unable to modify the settings without said password.
This should be uploaded to your Script Library as a PowerShell script. You can then run it on devices using a Scheduled Script or Search tab).
# This script will attempt to set an options password for Teamviewer Host installations.
# The password will be set to 'lockdown'.
Write-Host "Attempting to set password."
Write-Host "Stopping TeamViewer service."
# Stops TeamViewer process
$tvProcess = Get-Process -Name "teamviewer" -ErrorAction SilentlyContinue
if ($tvProcess) {
Stop-Process -InputObject $tvProcess -Force
}
Write-Host "Waiting for TeamViewer service to stop."
# Suspends new commands for 15 seconds
Start-Sleep -s 15
Write-Host "Adding registry keys."
# Adds registry keys enabling and setting options password to 'lockdown'
reg add "HKEY_LOCAL_MACHINESOFTWAREWow6432NodeTeamViewer" /v Security_Adminrights /t REG_DWORD /d 1 /f
reg add "HKEY_LOCAL_MACHINESOFTWAREWow6432NodeTeamViewer" /v OptionsPasswordAES /t REG_BINARY /d a4e0dc227fa91d2592723981b456a800931130940be507d896bdc29b37d16f73 /f
Write-Host "Starting TeamViewer service."
# Starts TeamViewer process
$tvProcess = Get-Process -Name "teamviewer" -ErrorAction SilentlyContinue
if ($tvProcess) {
Start-Process -InputObject $tvProcess -Force
}
Write-Host "Script complete."
