diff --git a/CheckTeamviewerVersion.ps1 b/CheckTeamviewerVersion.ps1 new file mode 100644 index 0000000..be230e5 --- /dev/null +++ b/CheckTeamviewerVersion.ps1 @@ -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('').trim('Currently not on Nagios Exchange** + +### 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