Skip to content

Commit 0bfc693

Browse files
committed
Fix github release install args
1 parent 937d7a9 commit 0bfc693

1 file changed

Lines changed: 14 additions & 6 deletions

File tree

script/windows_exporter_installer.ps1

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
# Script ver 2025071001
44

55
# Changelog
6+
# 2025-07-25: - Fix Downloading from git function returns too much info
67
# 2025-07-10: - Add error message on MSI install failure
78
# 2025-07-07: - Update default collectors for windows_exporter 0.31+
89
# 2025-03-24: - Re-enable firewall exception, disabled by upstream
@@ -55,8 +56,9 @@ function DownloadGitRelease {
5556
$releasesUri = "https://api.github.com/repos/$git_org/$git_repo/releases/latest"
5657
$downloadUri = ((Invoke-RestMethod -Method GET -Uri $releasesUri).assets | Where-Object name -like $filenamePattern ).browser_download_url
5758
$MSI_FILE = Join-Path -Path $script_path -ChildPath $(Split-Path -Path $downloadUri -Leaf)
58-
Write-Output "Downloading github release to $MSI_FILE"
59+
Write-Host "Downloading github release to $MSI_FILE"
5960
Invoke-WebRequest -Uri $downloadUri -Out $MSI_FILE
61+
return $MSI_FILE
6062
}
6163

6264

@@ -189,7 +191,12 @@ try {
189191
Write-Output "Found windows_exporter in $MSI_FILE"
190192
} catch {
191193
Write-Output "No windows_exporter msi file found. Trying to download a copy from github"
192-
DownLoadGitRelease
194+
try {
195+
$MSI_FILE = DownLoadGitRelease
196+
} catch {
197+
Write-Error "Cannot download git release"
198+
exit 1
199+
}
193200
}
194201

195202

@@ -217,11 +224,12 @@ if ($null -ne $app) {
217224
$app.Uninstall() | Out-Null
218225
}
219226

227+
$MSI_ARGS="/passive /i $MSI_FILE ENABLED_COLLECTORS=$COLLECTORS LISTEN_PORT=$LISTEN_PORT ADDLOCAL=$ADD_LOCAL"
220228
Write-Output "Installing windows exporter with following command line:"
221-
Write-Output "msiexec.exe /passive /i $MSI_FILE ENABLED_COLLECTORS=$COLLECTORS LISTEN_PORT=$LISTEN_PORT ADDLOCAL=$ADD_LOCAL"
222-
msiexec.exe /passive /i $MSI_FILE ENABLED_COLLECTORS="$COLLECTORS" LISTEN_PORT=$LISTEN_PORT ADDLOCAL=$ADD_LOCAL
223-
if ($LASTEXITCODE -ne 0) {
224-
Write-Output "Failed to install $MSI_FILE - See event logs"
229+
Write-Output "msiexec.exe $MSI_ARGS"
230+
$exit_code = (Start-Process -FilePath msiexec.exe -ArgumentList $MSI_ARGS -Wait -PassThru).ExitCode
231+
if ($exit_code -ne 0) {
232+
Write-Output "Failed to install $MSI_FILE - See event logs, exit_code = $exit_code"
225233
Start-Sleep -s 15
226234
exit 1
227235
}

0 commit comments

Comments
 (0)