Skip to content

Commit

Permalink
Merge pull request #8 from sawft99/AddTeamViewerCheck
Browse files Browse the repository at this point in the history
Add team viewer check script
  • Loading branch information
sawft99 authored Jun 26, 2024
2 parents ee008f4 + fc85480 commit d0983d0
Show file tree
Hide file tree
Showing 4 changed files with 100 additions and 2 deletions.
75 changes: 75 additions & 0 deletions CheckTeamviewerVersion.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
#Check if latest Teamviewer version is installed

[System.UriBuilder]$LatestVersionURL = 'https://www.teamviewer.com/en-us/download/windows/'

#If more than X minor versions behind, report as critical
#Example if $MaxMinorDif = 4: Latest = 15.5.0, Installed = 15.2.0, reports as warning. If Latest = 15.5.0, Installed = 15.0.0, then it will report as critical
#Being behind by 1 or more major versions is automatically critical
#Being behind by 1 or more build numbers is automatically minor
[int]$MaxMinorDif = 4

#---------

#Detect x64 or x86 TV
[System.IO.FileInfo]$TVExe = ${env:ProgramFiles} + '\' + 'TeamViewer' + '\' + 'TeamViewer.exe'

if ($TVExe.Exists -eq $false) {
[System.IO.FileInfo]$TVExe = ${env:ProgramFiles(x86)} + '\' + 'TeamViewer' + '\' + 'TeamViewer.exe'
}
if ($TVExe.Exists -eq $false) {
Write-Output 'UNKNOWN: Teamviewer not found or not installed'
exit 3
}

#Forces TLS 1.2
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12

#Find latest version from TV site
#$WebPage = New-Object -ComObject "HTMLFile"
#$Content = (Invoke-WebRequest -Uri $LatestVersionURL.Uri -UseBasicParsing).Content.ToString()
#$WebPage.write([ref]$Content)

#More compatible version
$Content = (Invoke-WebRequest -Uri $LatestVersionURL.Uri -UseBasicParsing).Content

[string]$LatestVersion = ((($Content -split '\n') | Where-Object {$_ -cmatch 'Current version: '} | Select-Object -First 1).TrimStart('Current version: ')).TrimEnd('')
$LatestVersion = $LatestVersion.Trim('<span data-dl-version-label>').trim('</')
$LatestVersion = ($LatestVersion -split '\.' | Select-Object -First 3) -join '.'
[version]$LatestVersion = $LatestVersion

#Compare newest verison and current version
[string]$InstalledVersion = $TVExe.VersionInfo.FileVersion
$InstalledVersion = ($InstalledVersion -split '\.' | Select-Object -First 3) -join '.'
[version]$InstalledVersion = $InstalledVersion

#Determine difference in version numbers
$MajorDif = $LatestVersion.Major - $InstalledVersion.Major
$MinorDif = $LatestVersion.Minor - $InstalledVersion.Minor

#Report
if ($LatestVersion -eq $InstalledVersion) {
Write-Output 'OK: TeamViewer is up to date'
Write-Output "Latest Version: $LatestVersion"
Write-Output "Current Version: $InstalledVersion"
$LASTEXITCODE = 0
} elseif (($MajorDif -le 0) -and ($MinorDif -gt 0) -and ($MinorDif -lt $MaxMinorDif)) {
Write-Output 'WARNING: TeamViewer is out of date'
Write-Output "Latest Version: $LatestVersion"
Write-Output "Current Version: $InstalledVersion"
$LASTEXITCODE = 1
} elseif (($MajorDif -gt 0) -or ($MinorDif -ge $MaxMinorDif)) {
Write-Output 'CRITICAL: TeamViewer is VERY out of date'
Write-Output "Latest Version: $LatestVersion"
Write-Output "Current Version: $InstalledVersion"
$LASTEXITCODE = 2
} elseif ($LatestVersion -ne $InstalledVersion) {
Write-Output 'WARNING: TeamViewer is out of date'
Write-Output "Latest Version: $LatestVersion"
Write-Output "Current Version: $InstalledVersion"
$LASTEXITCODE = 1
} else {
Write-Output 'UNKNOWN: Issue with determining versions'
$LASTEXITCODE = 3
}

exit $LASTEXITCODE
Binary file added Examples/Ex-TV1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Examples/Ex-TV2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
27 changes: 25 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,15 @@ Various Nagios plugins
- [CheckPSSignatures.ps1](#checkpssignaturesps1)
- [Arguments](#arguments-2)
- [Example](#example-2)
- [CheckWazuhVersion.ps1](#checkwazuhversionps1)
- [CheckTeamviewerVersion.ps1](#checkteamviewerversionps1)
- [Arguments](#arguments-3)
- [Example](#example-3)
- [CheckWinLocalAccounts.ps1](#checkwinlocalaccountsps1)
- [CheckWazuhVersion.ps1](#checkwazuhversionps1)
- [Arguments](#arguments-4)
- [Example](#example-4)
- [CheckWinLocalAccounts.ps1](#checkwinlocalaccountsps1)
- [Arguments](#arguments-5)
- [Example](#example-5)

## [CheckForRestartsAndUptime.ps1](./CheckForRestartsAndUptime.ps1)

Expand Down Expand Up @@ -85,6 +88,26 @@ Various Nagios plugins
![Ex-Sigs1.png](./Examples/Ex-Sigs1.png)
![Ex-Sigs2.png](./Examples/Ex-Sigs2.png)

## [CheckTeamviewerVersion.ps1](./CheckTeamviewerVersion.ps1)

- Checks if computer is running an outdated Teamviewer
- Inside script there is a variable for $MaxMinorDif with a default value of '4'
- This will determine the number of revisions between the latest version and the installed version
- If it is more than 4 minor revisions behind, or 1+ major release behind, it reports CRITICAL
- 4 or less revisions reports as WARNING
- **<ins>Currently not on Nagios Exchange</ins>**

### Arguments

- N/A

### Example

- `check_ncpa.py -t 'TOKEN' -P 5693 -M 'plugins/CheckTeamviewerVersion.ps1'`

![Ex-TV1.png](./Examples/Ex-TV1.png)
![Ex-TV2.png](./Examples/Ex-TV2.png)

## [CheckWazuhVersion.ps1](./CheckWazuhVersion.ps1)

- Checks if computer is running an outdated Wazuh agent
Expand Down

0 comments on commit d0983d0

Please sign in to comment.