PowerShell 7 Tutorials for Beginners #10 : Error Handling (Try Catch Finally)

Поделиться
HTML-код
  • Опубликовано: 4 ноя 2024

Комментарии • 15

  • @richardgarrow9260
    @richardgarrow9260 Год назад +3

    Jack I am quite surprised that you are not getting more hits as these videos are really good. Thanks

  • @shashikantovhal1769
    @shashikantovhal1769 Год назад +6

    Thank you so much for creating this series. As a beginner , the series helped me to become fearless about powershell.

  • @aeylia7535
    @aeylia7535 Год назад

    The quality of these videos man! I know for sure you'll make it big here

  • @kennethpaige7036
    @kennethpaige7036 Год назад

    This series was very helpful .. thank you so much!

  • @jadelise
    @jadelise 8 месяцев назад +1

    Nice Job! bite sized chunks, easy to digest. I will be subscribing

  • @Jon-rp4st
    @Jon-rp4st 2 года назад +1

    Thanks a lot, nice person!

  • @fonsohalbert
    @fonsohalbert Год назад

    This is amazing! Thank you for uploading

  • @vitorrejano670
    @vitorrejano670 Год назад +1

    Great video!

  • @MrWogle1
    @MrWogle1 Год назад

    One of my favorite things to do with error handling in PowerShell is to structure the catch statement like this:
    $ErrorMessage = "Error occurred when attempting to do X on Y. This is a terminating error.`n$($Error[0])"
    Write-ErrorLog -LogMessage = $ErrorMessage
    return $ErrorMessage
    This will spit out a custom error message that you write yourself, and then on a new line spit out the text from the last error that happened (which is the one you just caught).
    It makes debugging waaaaay easier.

  • @Jan-nu6zc
    @Jan-nu6zc 11 месяцев назад

    Thank u! Great Video

  • @riccarrasquilla379
    @riccarrasquilla379 6 месяцев назад

    thanks for the video

  • @netor-3y4
    @netor-3y4 10 месяцев назад +1

    $ErrorActionPreference = "Stop"
    try {
    $filePath = "C:\Scripts\10 - Error Handling"
    $files = Get-ChildItem -Path $filePath
    foreach ($file in $files) {
    Write-Output $file.Name
    }
    Write-Output "This is after the loop"
    } catch {
    Write-Output "Caught an error"
    } finally {
    Write-Output "This always runs no matter what!"
    }

  • @shokiroffff
    @shokiroffff 2 месяца назад

    nice

  • @ВикторЛарионов-й3к
    @ВикторЛарионов-й3к 8 месяцев назад

    thanks