From 84bb2695d7deaffcaed2b731f50a6b81b26c2e5f Mon Sep 17 00:00:00 2001 From: Stefan Chivu Date: Wed, 15 Feb 2023 08:42:08 +0000 Subject: [PATCH] ceph-windows: Fixed txt event log dump The event log collection script was throwing an error if no event logs could be found for the filters applied. Therefore, the Get-WinEvent call in DumpEventLogTxt has been modified to silently continue if such case arises. Signed-off-by: Stefan Chivu --- scripts/ceph-windows/collect-event-logs.ps1 | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/scripts/ceph-windows/collect-event-logs.ps1 b/scripts/ceph-windows/collect-event-logs.ps1 index de870aeb..ffdb123f 100644 --- a/scripts/ceph-windows/collect-event-logs.ps1 +++ b/scripts/ceph-windows/collect-event-logs.ps1 @@ -26,7 +26,13 @@ function DumpEventLogTxt($path){ $logName = $logName.replace(" ","-").replace("/", "-").replace("\", "-") Write-Output "exporting "$i.LogName" as "$logName $logFile = Join-Path $path $logName - Get-WinEvent -FilterHashtable @{LogName=$i.LogName;StartTime=$(Get-Date).AddHours(-24)} | Format-Table -AutoSize -Wrap > $logFile + Get-WinEvent ` + -ErrorAction SilentlyContinue ` + -FilterHashtable @{ + LogName=$i.LogName; + StartTime=$(Get-Date).AddHours(-6) + } | ` + Format-Table -AutoSize -Wrap > $logFile } } -- 2.47.3