From 7b076c65a97812000f9a93c021510e37ca650d18 Mon Sep 17 00:00:00 2001 From: Paulo Janotti Date: Wed, 17 Jan 2024 09:52:29 -0800 Subject: [PATCH] Fix Windows testing checking for legacy versions of the collector --- .github/workflows/scripts/win-test-services.ps1 | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/.github/workflows/scripts/win-test-services.ps1 b/.github/workflows/scripts/win-test-services.ps1 index 0e4d3dce21..c7b7ed42b6 100644 --- a/.github/workflows/scripts/win-test-services.ps1 +++ b/.github/workflows/scripts/win-test-services.ps1 @@ -11,11 +11,16 @@ $ErrorActionPreference = 'Stop' Set-PSDebug -Trace 1 function check_collector_svc_environment([hashtable]$expected_env_vars) { - $env_array = Get-ItemPropertyValue -Path "HKLM:\SYSTEM\CurrentControlSet\Services\splunk-otel-collector" -Name "Environment" $actual_env_vars = @{} - foreach ($entry in $env_array) { - $key, $value = $entry.Split("=", 2) - $actual_env_vars.Add($key, $value) + try { + $env_array = Get-ItemPropertyValue -Path "HKLM:\SYSTEM\CurrentControlSet\Services\splunk-otel-collector" -Name "Environment" + foreach ($entry in $env_array) { + $key, $value = $entry.Split("=", 2) + $actual_env_vars.Add($key, $value) + } + } catch { + Write-Host "Assuming an old version of the collector with environment variables at the machine scope" + $actual_env_vars = [Environment]::GetEnvironmentVariables("Machine")<#Do this if a terminating exception happens#> } foreach ($key in $expected_env_vars.Keys) {