Tag: PowerShell error handling best practices

Exception or Error handling in PowerShell -Try/Catch/Finally Block Example

Exception or Error handling in PowerShell -Try/Catch/Finally Block Example

 7,695 total views

 7,695 total views In this post, I will show that how we can handle the exception in PowerShell coding using the try/catch/finally block and how we can write the error or exception message into the log file. Exception handling using try/catch/finally block PowerShell example: cls $fileName = “File_Uploading_Report” $enddate = (Get-Date).tostring(“yyyyMMddhhmmss”) $logFileName = $fileName +”_”+ $enddate+”_Log.txt”

Continue reading