]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph-build.git/commitdiff
ceph-windows: Fixed txt event log dump 2112/head
authorStefan Chivu <schivu@cloudbasesolutions.com>
Wed, 15 Feb 2023 08:42:08 +0000 (08:42 +0000)
committerStefan Chivu <schivu@cloudbasesolutions.com>
Wed, 15 Feb 2023 08:42:14 +0000 (08:42 +0000)
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 <schivu@cloudbasesolutions.com>
scripts/ceph-windows/collect-event-logs.ps1

index de870aeb3973f6a56ba045156378bfed8fd0234a..ffdb123f085693f0ad755064b1cfc5e92aa8f73f 100644 (file)
@@ -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
     }
 }