-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #8 from sawft99/AddTeamViewerCheck
Add team viewer check script
- Loading branch information
Showing
4 changed files
with
100 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters