TEXT

Wednesday, September 21, 2022

Simple try and catch statement

 Here is simple example of try and catch statement.

 

# TRY CATCH

Try{

<Code Goes HERE>

}Catch{

$errormessage = $($PSItem.ToString())

  Write-Warning 'Error has occurred'

  Write-host 'Problem FOUND:' $errormessage -ForegroundColor Red -BackgroundColor White

}

 




No comments:

Post a Comment

Simple Function Do Something

   Use template below to create simple PS function    # Simple Function Do Something # Change $ReportName   function Fu...