Function MyFunction { [cmdletbinding()] Param( [string]$Name="Chaokoh") write-verbose "Running the function" #$PSBoundParameters Get-Date write $name Write-Warning "Foo Warning $(Get-Date)" -WarningVariable $PSBoundParameters.WarningVariable Try { Write-Host "I'm trying..." -Foreground green Write-Error "I am problem $(Get-Random) $(Get-Date)" -ErrorAction Stop } Catch { Write-Host "Exception caught" -ForegroundColor red Write-Warning "oops $(Get-date)" -WarningVariable $PSBoundParameters.WarningVariable } Write-Warning "Foo Warning $(Get-Date)" -WarningVariable $PSBoundParameters.WarningVariable write-error "I am another error" Get-date }