These scripts are designed to install, uninstall, and check the presence of TeamViewer Host on Windows machines. They can read parameters from the command line, a configuration file (config.json
), or use default values. If any required parameter is missing and cannot be resolved, the scripts will fail with an appropriate error message.
This repository is licensed under the GNU General Public License v3.0 (GPLv3).
Developed by Tommy Vange Rød.
The scripts use a configuration file (config.json
) to store default values for the TeamViewer Host settings. Here is an example of the configuration file:
{
"ConfigID": "ABC123",
"AssignmentID": "AAAAABBBBBCCCCDDDDEEEE11112222333344445555=",
"Logging": false,
"NoShortcut": true,
"DeviceAlias": "%COMPUTERNAME%",
"InstallerPath": "./TeamViewer_Host.msi",
"InstallSecurityKeyRedirection": false,
"SettingsFile": "./TeamViewer_Settings.tvopt"
}
ConfigID
: The custom configuration ID for TeamViewer installation.AssignmentID
: The assignment ID for TeamViewer.Logging
: Enables transcript logging if set totrue
.NoShortcut
: If set totrue
, disables the creation of desktop shortcuts during installation.DeviceAlias
: Specifies the device alias. If not provided, defaults to%COMPUTERNAME%
.InstallerPath
: The path to theTeamViewer_Host.msi
installer. Defaults to./TeamViewer_Host.msi
.InstallSecurityKeyRedirection
: Installs security key redirection during if set totrue
. Default isfalse
.SettingsFile
: Specifies the path to a settings file that contains configuration settings for TeamViewer. Defaults to nothing unless specified.
You must download the TeamViewer_Host.msi
installer from the TeamViewer Management Console. Once downloaded, place the installer in the same directory as the script or specify the path using the InstallerPath
parameter.
You can also use these direct links:
The links are to TeamViewer's official download server. The downloads include the MSI-package for both TeamViewer Host and TeamVIewer Full.
The scripts assume relative paths for the config.json
. It uses a relative path to config.json
in the same directory as the script. This ensures that the scripts can locate the necessary files correctly when deployed in different environments, such as through Intune.
The InstallerPath
parameter supports both relative and absolute paths. By default, it uses a relative path to TeamViewer_Host.msi
in the same directory as the script. You can specify an absolute path if the installer is located elsewhere on the system.
The install script adds TeamViewer using the specified parameters.
To run the install script, use the following command:
.\install.ps1 -ConfigID "<ConfigID>" -AssignmentID "<AssignmentID>" [-Logging] [-NoShortcut] [-DeviceAlias "<DeviceAlias>"] [-InstallerPath "<InstallerPath>"] [-InstallSecurityKeyRedirection] [-SettingsFile "<SettingsPath>"]
ConfigID
: The configuration ID for TeamViewer installation.AssignmentID
: The assignment ID for TeamViewer.- [Optional]
Logging
: Enables transcript logging if set. - [Optional]
NoShortcut
: Disables the creation of desktop shortcuts if set. - [Optional]
DeviceAlias
: Specifies the device alias. Defaults to%COMPUTERNAME%
. - [Optional]
InstallerPath
: Specifies the path to theTeamViewer_Host.msi
installer. Defaults to./TeamViewer_Host.msi
. - [Optional]
InstallSecurityKeyRedirection
: If set, addsINSTALLSECURITYKEYREDIRECTION=1
to the MSI install arguments. Defaults to false. - [Optional]
SettingsFile
: Specifies the path to a settings file. AddsSETTINGSFILE="path"
to the MSI arguments. Defaults to nothing.
If a parameter is not provided via the command line, the script will attempt to read it from the config.json
file. If the parameter is still not available, the script will fail and provide an error message.
To specify values directly via the command:
.\install.ps1 -ConfigID "ABC123" -AssignmentID "AAAAABBBBBCCCCDDDDEEEE11112222333344445555=" -Logging -NoShortcut -DeviceAlias "ACCOUNTING_%COMPUTERNAME%" -InstallerPath "./TeamViewer_Host.msi" -InstallSecurityKeyRedirection -SettingsFile "./TeamViewer_Settings.tvopt"
To use the default values from the configuration file:
.\install.ps1 -Logging
- Start the installation of TeamViewer using
msiexec.exe
. - Wait for 30 seconds for the installation to complete.
- Verify the existence of
TeamViewer.exe
. - Run the assignment command with the provided
AssignmentID
andDeviceAlias
.
The uninstall script removes TeamViewer Host using the specified parameters.
To run the uninstall script, use the following command:
.\uninstall.ps1 [-Logging]
- [Optional]
Logging
: Enables transcript logging if set.
If a parameter is not provided via the command line, the script will attempt to read it from the config.json
file. If the parameter is still not available, the script will fail and provide an error message.
To specify values directly via the command:
.\uninstall.ps1 -Logging
To use the default values from the configuration file:
.\uninstall.ps1
- Retrieve the product GUID for TeamViewer.
- Uninstall TeamViewer using
msiexec.exe
.
The check TeamViewer Host script verifies if TeamViewer Host is installed and outputs "Detected" or "NotDetected". It uses exit codes compatible with Intune: 0
for success (detected) and 1
for failure (not detected).
To run the check script, use the following command:
.\check.ps1 [-Logging]
If you are running this as a check script in environments such as Intune, it is best to populate the variables directly in the code. Intune does not allow passing CLI arguments or using config.json
for check scripts, so the only way is to set the variables within the script itself.
The script includes a section designed for this purpose:
# Manually fill these variables if using environments like Intune
# (Intune does not support CLI arguments or configuration files for check scripts)
#
# $ManualLogging = $false # Set to $true to enable logging
To use this feature, simply uncomment these lines and populate the variables with your desired values. The script will prioritize these manual settings over CLI arguments and config.json, ensuring that the specified data is used during execution. This approach allows seamless integration with Intune and similar deployment tools.
- [Optional]
Logging
: Enables transcript logging if set.
If a parameter is not provided via the command line, the script will attempt to read it from the config.json
file. If the parameter is still not available, the script will fail and provide an error message.
To specify values directly via the command:
.\check.ps1 -Logging
To use the default values from the configuration file:
.\check.ps1
- Check if the
Logging
parameter is provided. - Start transcript logging if enabled.
- Check if
TeamViewer.exe
exists in the expected locations. - Output "Detected" if TeamViewer is found, otherwise output "NotDetected".
All scripts support transcript logging to capture detailed information about the script execution. Logging can be enabled via the -Logging
parameter or the configuration file.
When logging is enabled, the scripts will start a PowerShell transcript at the beginning of the execution and stop it at the end. This transcript will include all commands executed and their output, providing a detailed log of the script's actions.
Logging can be enabled by setting the -Logging
parameter when running the script, or by setting the Logging
property to true
in the config.json
file.
The log files are stored in the temporary directory of the user running the script. The log file names follow the pattern:
- For the install script:
installation_log_TeamViewerHost_${ConfigID}.txt
- For the uninstall script:
uninstallation_log_TeamViewer.txt
- For the check script:
check_TeamViewerHost_log.txt
Example log file paths:
C:\Users\<Username>\AppData\Local\Temp\installation_log_TeamViewerHost_ABC123.txt
C:\Users\<Username>\AppData\Local\Temp\uninstallation_log_TeamViewer.txt
C:\Users\<Username>\AppData\Local\Temp\check_TeamViewerHost_log.txt
System Account Exception: When scripts are run as the System account, such as during automated deployments or via certain administrative tools, the log files will be stored in the C:\Windows\Temp
directory instead of the user's local temporary directory.
To enable logging via the command line:
.\install.ps1 -ConfigID "ABC123" -AssignmentID "AAAAABBBBBCCCCDDDDEEEE11112222333344445555="
Or by setting the Logging
property in the configuration file:
{
"ConfigID": "ABC123",
"AssignmentID": "AAAAABBBBBCCCCDDDDEEEE11112222333344445555=",
"Logging": true,
"NoShortcut": true,
"DeviceAlias": "%COMPUTERNAME%"
"InstallSecurityKeyRedirection": false,
"SettingsFile": "./TeamViewer_Settings.tvopt"
}
All scripts include error handling to provide clear messages when parameters are missing or actions fail. If any required parameter is missing and cannot be resolved, the scripts will fail with an appropriate error message.
- Ensure that you have the necessary permissions to install and uninstall TeamViewer Host on the machine where these scripts are executed.
- The scripts assume that the necessary files are available at the specified paths.
If you encounter any issues, ensure that all parameters are correctly specified and that the necessary files are available at the provided paths. Check the error messages provided by the scripts for further details on what might have gone wrong.
The GNU General Public License v3.0 (GPLv3) is a free, copyleft license for software and other creative works. It ensures your freedom to share, modify, and distribute all versions of a program, keeping it free software for everyone.
Full license can be read here or at gnu.org.
-
Freedom to Share and Change:
- You can distribute copies of GPLv3-licensed software.
- Access the source code.
- Modify the software.
- Create new free programs using parts of it.
-
Responsibilities:
- If you distribute GPLv3 software, pass on the same freedoms to recipients.
- Provide the source code.
- Make recipients aware of their rights.
-
No Warranty:
- No warranty for this free software.
- Developers protect your rights through copyright and this license.
-
Marking Modifications:
- Clearly mark modified versions to avoid attributing problems to previous authors.
This README provides comprehensive information about the TeamViewer Deployment Scripts project, covering configuration, installation, uninstallation, checking, logging, error handling, and troubleshooting.