-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCheckNCPAVersion.ps1
33 lines (27 loc) · 1.13 KB
/
CheckNCPAVersion.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#Check for latest version of NCPA
[System.IO.FileInfo]$NCPAExe = $env:ProgramFiles + '\Nagios\NCPA\ncpa.exe'
[System.UriBuilder]$NCPAVersionURL = 'https://raw.githubusercontent.com/NagiosEnterprises/ncpa/master/VERSION'
#Forces TLS 1.2
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
#Find latest version from GitHub
$LatestVersion = ((Invoke-WebRequest $NCPAVersionURL.Uri -UseBasicParsing).Content).TrimEnd('')
$CurrentVersion = $NCPAExe.VersionInfo.ProductVersion
#------------------------
if (!(Test-Path $NCPAExe)) {
Write-Output 'CRITICAL: NCPA not found'
$LASTEXITCODE = 2
} elseif ($CurrentVersion -eq $LatestVersion) {
Write-Output 'OK: NCPA is up to date'
Write-Output "Latest Version: $LatestVersion"
Write-Output "Current Version: $CurrentVersion"
$LASTEXITCODE = 0
} elseif ($CurrentVersion -ne $LatestVersion) {
Write-Output 'WARNING: NCPA is out of date'
Write-Output "Latest Version: $LatestVersion"
Write-Output "Current Version: $CurrentVersion"
$LASTEXITCODE = 1
} else {
Write-Output 'UNKNOWN: Unknown issue'
$LASTEXITCODE = 3
}
exit $LASTEXITCODE