Import-Module CoreFunctions -Force function Show-InvocationInfo { param ( $Invocation, [Switch] $End ) if ($End) { Write-LogDebug "" } else { Write-LogDebug "" Write-LogDebug "" foreach ($Parameter in $Invocation.MyCommand.Parameters) { foreach ($Key in $Parameter.Keys) { $Type = $Parameter[$Key].ParameterType.FullName foreach ($Value in $Invocation.BoundParameters[$Key]) { Write-LogDebug "[$Type] $Key = '$Value'" } } } Write-LogDebug "" } } $TrapHandler = { Write-LogError @("", $_) -EntireObject Write-LogError "" break } trap { &$TrapHandler } $ErrorActionPreference = 'Stop' <# # Usage example for Show-InvocationInfo function MyFunction { param ( [String] $Value1, [String] $Value2, [Int] $Int1 ) begin { Show-InvocationInfo $MyInvocation } end { Show-InvocationInfo $MyInvocation -End } process { trap { &$TrapHandler } # Main code here } } #>