Skip to content

Instantly share code, notes, and snippets.

@techdecline
Last active December 7, 2024 12:19
Show Gist options
  • Select an option

  • Save techdecline/53b687b6710dc63eae238303713efed7 to your computer and use it in GitHub Desktop.

Select an option

Save techdecline/53b687b6710dc63eae238303713efed7 to your computer and use it in GitHub Desktop.
aram (
[Parameter(Mandatory)]
[ValidateScript({Test-Path $_})]
[String]$Source
)
# Uninstall old releases
Write-Verbose "Searching old TeamViewer releases installed using MSI Wrapper"
$tvArr = Get-WmiObject -Query 'Select Name,IdentifyingNumber from Win32_Product where Name like "TeamViewer%Wrapper%"'
foreach ($tvInstance in $tvArr) {
Write-Verbose "Removing: $($tvInstance.Name) with ID $($tvInstance.IdentifyingNumber)"
$cmdParam = "/x $($tvInstance.IdentifyingNumber) /qn /l*v C:\Windows\Temp\tv_uninstall_$($tvInstance.IdentifyingNumber).txt"
$cmdExe = "msiexec.exe"
Start-Process -FilePath $cmdExe -ArgumentList $cmdParam -Wait
}
# Install TV14
Write-Verbose "Installing latest TeamViewer Release from source: $Source"
$msiFullName = (Get-ChildItem -Path $Source -Filter *.msi)[0].FullName
$cmdParam = "/i $msiFullName /qn /l*v C:\Windows\Temp\tv_install_$(get-date -Format yyyyMMdd).log"
$cmdExe = "msiexec.exe"
Start-Process -FilePath $cmdExe -ArgumentList $cmdParam -Wait
#requires -version 2
param (
[Parameter(Mandatory=$true)]
[ValidateScript({Test-Path $_})]
[String]$Source
)
# Uninstall old releases
Write-Verbose "Searching old TeamViewer releases installed using MSI Wrapper"
$tvArr = Get-WmiObject -Query 'Select Name,IdentifyingNumber from Win32_Product where Name like "TeamViewer%Wrapper%"'
foreach ($tvInstance in $tvArr) {
Write-Verbose "Removing: $($tvInstance.Name) with ID $($tvInstance.IdentifyingNumber)"
$cmdParam = "/x $($tvInstance.IdentifyingNumber) /qn /l*v C:\Windows\Temp\tv_uninstall_$($tvInstance.IdentifyingNumber).txt"
$cmdExe = "msiexec.exe"
Start-Process -FilePath $cmdExe -ArgumentList $cmdParam -Wait
}
# Install TV14
Write-Verbose "Installing latest TeamViewer Release from source: $Source"
$msiFullName = (Get-ChildItem -Path $Source -Filter *.msi).FullName
$cmdParam = "/i $msiFullName /qn /l*v C:\Windows\Temp\tv_install_$(get-date -Format yyyyMMdd).log"
$cmdExe = "msiexec.exe"
Start-Process -FilePath $cmdExe -ArgumentList $cmdParam -Wait
#requires -version 2
param (
[Parameter(Mandatory=$true)]
[ValidateScript({Test-Path $_})]
[String]$Source
)
# Uninstall old releases
Write-Verbose "Searching old TeamViewer releases installed using MSI Wrapper"
$tvArr = Get-WmiObject -Query 'Select Name,IdentifyingNumber from Win32_Product where Name like "TeamViewer%Wrapper%"'
foreach ($tvInstance in $tvArr) {
Write-Verbose "Removing: $($tvInstance.Name) with ID $($tvInstance.IdentifyingNumber)"
$msiProductCode = ($tvInstance.IdentifyingNumber) -replace "{|}",""
$cmdParam = "/x $msiProductCode /qn /l*v C:\Windows\Temp\tv_uninstall_msiProductCode.txt"
$cmdExe = "msiexec.exe"
Start-Process -FilePath $cmdExe -ArgumentList $cmdParam -Wait
}
# Install TV14
Write-Verbose "Installing latest TeamViewer Release from source: $Source"
$msiFullName = (Get-ChildItem -Path $Source -Filter *.msi).FullName
$cmdParam = "/i $msiFullName /qn /l*v C:\Windows\Temp\tv_install_$(get-date -Format yyyyMMdd).log"
$cmdExe = "msiexec.exe"
Start-Process -FilePath $cmdExe -ArgumentList $cmdParam -Wait
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment