Skip to content

Commit

Permalink
Added trap
Browse files Browse the repository at this point in the history
  • Loading branch information
lexiismadd committed Nov 24, 2022
1 parent 25b24fd commit b72527b
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions Standard-CT-Module/CT-PS-Standard.psm1
Original file line number Diff line number Diff line change
@@ -1,4 +1,15 @@

trap {
write-host "Terminating error $_"
Write-Host "Script $((Get-ChildItem $MyInvocation.PSCommandPath | Select-Object -Expand Name)) ended with exit code $($exiterror)."
write-host "Transcript stored at $($Transcript_log)."
Write-Host "Console output log stored at $($Output_log)"
Write-Host "API log stored at $($API_log)"
Write-Host "**********************"
Write-Host ""
exit $exiterror
}

function Initialize-Script {
[CmdletBinding()]
param()
Expand Down Expand Up @@ -31,6 +42,7 @@ function Initialize-Script {


#Transcript-Log "-------$('-' * $MyInvocation.MyCommand.Name.Length)----------"
Start-Transcript -Path $Transcript_log -Append -verbose:$VerbosePreference
Write-Log "**********************" -verbose:$VerbosePreference
Write-Log "Script $($ScriptName) starting." -verbose:$VerbosePreference

Expand Down

0 comments on commit b72527b

Please sign in to comment.