Snippet Name: try-catch
Tags: PowerShell
Created Date: 2020-06-09 15:29:04
Last Modified Date: 2020-06-09 15:29:04
— try-catch
Dependencies:
DBA Notes:
Sample Output:
try
{
}
catch
{
$e = $MyInvocation.MyCommand.Name + "|" + ((Get-Date).ToString("yyyy-MM-dd HH:mm:ss")) + "|`n"
for($i = $Error.Count -1;$i -ge 0;$i--) {$e = $e + " " + $Error[$i].ToString() + "|`n" }
Add-Content -Path '\\GADCDBBCK\cifs_sql_pd_backups\Releases\Documentation\DBADailyTasks\PowerShellResults\UniversalExecutionLog.txt' -Value $e
}