From 5861a46fd75b62a2eef4bd50e34bb4bc990fd610 Mon Sep 17 00:00:00 2001 From: Tamara Buch Date: Wed, 4 Mar 2026 11:03:54 -0600 Subject: [PATCH 1/3] retry out-file --- .../functions/public/Export-SplunkData.ps1 | 40 +++++++++++++++---- 1 file changed, 32 insertions(+), 8 deletions(-) diff --git a/src/UofISplunkCloud/functions/public/Export-SplunkData.ps1 b/src/UofISplunkCloud/functions/public/Export-SplunkData.ps1 index 8564e3b..18b1f20 100644 --- a/src/UofISplunkCloud/functions/public/Export-SplunkData.ps1 +++ b/src/UofISplunkCloud/functions/public/Export-SplunkData.ps1 @@ -176,6 +176,22 @@ function Export-SplunkData { } $Results = Invoke-RestMethod @IVRSplat + $Filename = "SearchResults_$(Get-Date -Format yyyyMMdd-HHmmss)" + + # Files are sometimes not generated correctly due to small transient issues in Azure Automation fabric infrastructure + function Write-WithRetry { + param( + [scriptblock]$WriteAction, + [string]$FilePath + ) + for ($i = 1; $i -le 3; $i++) { + & $WriteAction + if (Test-Path -Path $FilePath) { return } + Start-Sleep -Seconds 2 + } + throw "Failed to write $($FilePath) after 3 attempts." + } + #Return results If(!($Results)){ Write-Output -InputObject "No results" @@ -184,20 +200,28 @@ function Export-SplunkData { $Results } ElseIf($OutputMode -eq 'csv'){ - $Results | Out-File -Path ".\SearchResults_$(Get-Date -Format yyyyMMdd-HHmmss).csv" - Write-Output -InputObject "SearchResults_$(Get-Date -Format yyyyMMdd-HHmmss).csv" + Write-WithRetry -FilePath ".\$($Filename).csv" -WriteAction { + $Results | Out-File -Path ".\$($Filename).csv" + } + Write-Output -InputObject "$($Filename).csv" } ElseIf($OutputMode -like 'json*'){ - $Results | ConverTo-Json -Depth 10 | Out-File -Path ".\SearchResults_$(Get-Date -Format yyyyMMdd-HHmmss).json" - Write-Output -InputObject "SearchResults_$(Get-Date -Format yyyyMMdd-HHmmss).json" + Write-WithRetry -FilePath ".\$($Filename).json" -WriteAction { + $Results | ConvertTo-Json -Depth 10 | Out-File -Path ".\$($Filename).json" + } + Write-Output -InputObject "$($Filename).json" } ElseIf($OutputMode -eq 'xml'){ - $Results | Out-File -Path ".\SearchResults_$(Get-Date -Format yyyyMMdd-HHmmss).xml" - Write-Output -InputObject "SearchResults_$(Get-Date -Format yyyyMMdd-HHmmss).xml" + Write-WithRetry -FilePath ".\$($Filename).xml" -WriteAction { + $Results | Out-File -Path ".\$($Filename).xml" + } + Write-Output -InputObject "$($Filename).xml" } else{ - $Results | Out-File -Path ".\SearchResults_$(Get-Date -Format yyyyMMdd-HHmmss)" - Write-Output -InputObject "SearchResults_$(Get-Date -Format yyyyMMdd-HHmmss)" + Write-WithRetry -FilePath ".\$($Filename)" -WriteAction { + $Results | Out-File -Path ".\$($Filename)" + } + Write-Output -InputObject "$($Filename)" } } } From 6f588c4a658222ab1040c392d72d2f425f594b5e Mon Sep 17 00:00:00 2001 From: Tamara Buch Date: Wed, 4 Mar 2026 11:06:55 -0600 Subject: [PATCH 2/3] changelog++ --- CHANGELOG.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 680cdfc..f96fe72 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,6 +13,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Removed +## [1.1.6] - 2026-03-04 + +### Changed + +- Export-SplunkData: File generation in transient execution environments (e.g. Azure Automation runbooks) is susceptible to intermittent I/O failures. Added retry logic to handle cases where output files are not written due to short-lived environment instability. + ## [1.1.5] - 2024-05-23 ### Changed From 95f0521c4d9d6e7ec6c885f865f6a6dabdf84961 Mon Sep 17 00:00:00 2001 From: Tamara Buch Date: Wed, 4 Mar 2026 13:09:23 -0600 Subject: [PATCH 3/3] prep for release --- src/UofISplunkCloud/UofISplunkCloud.psd1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/UofISplunkCloud/UofISplunkCloud.psd1 b/src/UofISplunkCloud/UofISplunkCloud.psd1 index 1a75caf..7e1e4d5 100644 --- a/src/UofISplunkCloud/UofISplunkCloud.psd1 +++ b/src/UofISplunkCloud/UofISplunkCloud.psd1 @@ -10,7 +10,7 @@ RootModule = 'UofISplunkCloud.psm1' # Version number of this module. -ModuleVersion = '1.1.5' +ModuleVersion = '1.1.6' # Supported PSEditions # CompatiblePSEditions = @()