diff --git a/toolbox/s3_backup_transfer.ps1 b/toolbox/s3_backup_transfer.ps1 index b33a742..107449d 100644 --- a/toolbox/s3_backup_transfer.ps1 +++ b/toolbox/s3_backup_transfer.ps1 @@ -79,10 +79,15 @@ if ($FolderName -eq "all") { function Write-AppEventLog { param([string]$Type, [int]$Id, [string]$Message) $EventSource = "SQLBackupToS3" - if (-not [System.Diagnostics.EventLog]::SourceExists($EventSource)) { - try { New-EventLog -LogName Application -Source $EventSource } catch { } + try { + if (-not [System.Diagnostics.EventLog]::SourceExists($EventSource)) { + New-EventLog -LogName Application -Source $EventSource + } + Write-EventLog -LogName Application -Source $EventSource -EntryType $Type -EventId $Id -Message $Message + } catch { + # Ignorujemy błędy EventLog (np. brak uprawnień administratora) + # Informacja i tak została już wypisana na ekran przez Write-Host } - try { Write-EventLog -LogName Application -Source $EventSource -EntryType $Type -EventId $Id -Message $Message } catch { } } # ========================================================