Skip to content

Commit acfc53e

Browse files
committed
Add windows agent version check
1 parent 9bd59e6 commit acfc53e

File tree

2 files changed

+20
-0
lines changed

2 files changed

+20
-0
lines changed

tasks/check.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,10 @@
2929
"openvox_bootstrap/lib/openvox_bootstrap/task.rb",
3030
"openvox_bootstrap/tasks/check.rb"
3131
]
32+
},
33+
{
34+
"name": "check_windows.ps1",
35+
"requirements": ["powershell"]
3236
}
3337
]
3438
}

tasks/check_windows.ps1

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
$rootPath = 'HKLM:\SOFTWARE\Puppet Labs\Puppet'
2+
3+
$reg = Get-ItemProperty -Path $rootPath -ErrorAction SilentlyContinue
4+
if ($null -ne $reg) {
5+
if ($null -ne $reg.RememberedInstallDir64) {
6+
$loc = $reg.RememberedInstallDir64+'VERSION'
7+
} elseif ($null -ne $reg.RememberedInstallDir) {
8+
$loc = $reg.RememberedInstallDir+'VERSION'
9+
}
10+
}
11+
12+
if ( ($null -ne $loc) -and (Test-Path -Path $loc) ) {
13+
Write-Output "{`"version`":`"$(Get-Content -Path $loc -ErrorAction Stop)`",`"source`":`"$($loc.replace('\', '/'))`"}"
14+
} else {
15+
Write-Output '{"version":null,"source":null}'
16+
}

0 commit comments

Comments
 (0)