diff --git a/Bootstrap.ps1 b/Bootstrap.ps1 index 3d4b3d1..b1a96d1 100644 --- a/Bootstrap.ps1 +++ b/Bootstrap.ps1 @@ -119,7 +119,7 @@ if ($config.logging.enabled) { # Rename log file to include the job name. try { - Rename-Item -Path $logFile -NewName "$(Split-Path $newLogfile -Leaf)" + Rename-Item -Path $logFile -NewName "$(Split-Path $newLogfile -Leaf)" -ErrorAction Stop } catch { Write-Output "ERROR: Failed to rename log file: $_" | Out-File $logFile -Append diff --git a/resources/Logger.psm1 b/resources/Logger.psm1 index 76d7116..a50f12b 100644 --- a/resources/Logger.psm1 +++ b/resources/Logger.psm1 @@ -87,7 +87,12 @@ function Stop-Logging { param() if ($PSCmdlet.ShouldProcess('log file', 'Stop-Transcript')) { Write-LogMessage -Tag 'INFO' -Message 'Stopping transcript logging.' - Stop-Transcript + try { + Stop-Transcript + } + catch { + Write-LogMessage -Tag 'ERROR' -Message 'Failed to stop transcript logging.' + } } }