Тёмный

How to use PowerShell Try, Catch and the Write-Verbose and Write-Debug 

John Savill's Technical Training
Подписаться 277 тыс.
Просмотров 20 тыс.
50% 1

A look at a few key constructs to help handle errors and troubleshooting in your PowerShell scripts.
My Files - github.com/johnthebrit/Random...
github.com/johnthebrit/Random...
Microsoft Document - docs.microsoft.com/en-us/powe...
00:00 Introduction
00:45 Error variable
02:22 Custom error variable
03:25 Try-Catch
05:01 ErrorAction
06:45 Error details
08:35 Error specific Catch
09:37 ErrorActionPreference
12:09 Errors from cmd.exe
13:25 Messages in scripts
15:09 Using CmdletBinding, Write-Verbose and Write-Debug
17:43 Summary and close

Наука

Опубликовано:

 

6 авг 2024

Поделиться:

Ссылка:

Скачать:

Готовим ссылку...

Добавить в:

Мой плейлист
Посмотреть позже
Комментарии : 71   
@raj35h
@raj35h 3 года назад
Awesome content as always. Can't believe you do all the work Ad free. Learnt so much from you over the years.
@NTFAQGuy
@NTFAQGuy 3 года назад
Glad you enjoy it!
@MrSujithn
@MrSujithn 3 года назад
Thank you very much John. Coming from a Unix/Linux background and having not much user for Powershell in the past, your videos have been a great help.
@NTFAQGuy
@NTFAQGuy 3 года назад
Great to hear!
@pierredang8084
@pierredang8084 2 года назад
Great video! I enjoy your teaching style/approach from all videos I've watched, easy to follow and well explained. Great for beginners!
@NTFAQGuy
@NTFAQGuy 2 года назад
Great, thanks for watching
@oem73
@oem73 2 года назад
Just AWESOME. Great explanation on how to use try/catch. Thank you, John!
@NTFAQGuy
@NTFAQGuy 2 года назад
Glad it was helpful!
@spiritmorin
@spiritmorin 3 года назад
Very useful. I just use this yesterday in Detection method in SCCM and Intune. But the verbose thing, that's bring me to the next level. Thank @John .
@NTFAQGuy
@NTFAQGuy 3 года назад
Glad it helped!
@abcde7290
@abcde7290 2 года назад
It's really impressive John what you do, and ad free! You are an amazing person!
@NTFAQGuy
@NTFAQGuy 2 года назад
Very kind, thanks 🤙
@amit_kala
@amit_kala 2 года назад
One word "Fantabulous" thank you for knowledge sharing, very few does what you're doing.. thank you again.
@TomWhi
@TomWhi 3 года назад
Brilliant, thank you John. I’ll be sharing this video and example scripts with my team!
@NTFAQGuy
@NTFAQGuy 3 года назад
Thanks
@ec0321
@ec0321 3 года назад
Very useful John. Thank you!
@ScottJoseph0227
@ScottJoseph0227 Год назад
Thanks John for your awesome instruction! I'm new to PS Programming & am loving the Journey. I also will be studying for the AZ-900 exam very soon. All the best to you!
@NTFAQGuy
@NTFAQGuy Год назад
Best of luck!
@cma9br
@cma9br 2 года назад
How simple is that! I've always wanted to deal with errors. Thanks a lot.
@NTFAQGuy
@NTFAQGuy 2 года назад
No problem!
@abrahamalaniz3468
@abrahamalaniz3468 3 года назад
I have tons of Powershell books, and seen a bunch of other RU-vidrs videos. You're definitely my top3 if not my top 1 favorite (:
@NTFAQGuy
@NTFAQGuy 3 года назад
Thanks
@Jaynext2
@Jaynext2 3 года назад
Useful video about debug and verbose. I will try to use it in my code. Thanks John 😃👍
@NTFAQGuy
@NTFAQGuy 3 года назад
Glad you liked it, thanks!
@rmontesdeoca
@rmontesdeoca Год назад
Outstanding explanation (as usual)
@marciobarbato
@marciobarbato 2 года назад
Wow, top content ! I wish I knew this before struggling with some basic concepts :D
@kevinbrekke2471
@kevinbrekke2471 3 года назад
Thank you for this! Now time to rewrite all my scripts haha. Definitely awesome content!
@NTFAQGuy
@NTFAQGuy 3 года назад
Thanks 😀
@iamdedlok
@iamdedlok 3 года назад
You are a champion John Savill, Thank You. I was exactly looking for this stuff yesterday. Coming from C# background, the try-catch behaves differently in Powershell! Thanks for unravelling it! woohoo ! Brain cells++
@NTFAQGuy
@NTFAQGuy 3 года назад
Awesome
@richard1101
@richard1101 3 месяца назад
Absolutely superb content - thank you!
@NTFAQGuy
@NTFAQGuy 3 месяца назад
Glad you enjoyed it!
@jreach4487
@jreach4487 2 года назад
Love the content, John.
@NTFAQGuy
@NTFAQGuy 2 года назад
Thanks
@RyanJohnson-kc5eu
@RyanJohnson-kc5eu 3 года назад
Very Useful. Thanks
@ibrahimabdeltawab6418
@ibrahimabdeltawab6418 Год назад
So helpful ❤
@dwelfusius
@dwelfusius 3 года назад
i love this! Thank you
@JBLewis
@JBLewis 3 года назад
Great use of the `Finally` block
@NTFAQGuy
@NTFAQGuy 3 года назад
Thanks!
@romanferguson4032
@romanferguson4032 2 года назад
man the debug and verbose are so cool
@NTFAQGuy
@NTFAQGuy 2 года назад
💯
@darryvakki9807
@darryvakki9807 Год назад
Thank you so v much Sir! greetings from ur fan
@newallst
@newallst 3 года назад
Awesome 😎
@NTFAQGuy
@NTFAQGuy 3 года назад
🤙
@shanebagel
@shanebagel 11 месяцев назад
John Savill is a bloody legend
@NTFAQGuy
@NTFAQGuy 11 месяцев назад
Lol thank you 🤙
@TheBondkartik
@TheBondkartik 3 года назад
Thanks for Azure Master Class brother. Actually found someone online who wants to impart knowledge with fun and not hook people
@NTFAQGuy
@NTFAQGuy 3 года назад
Very kind, thank you.
@nitti3723
@nitti3723 2 года назад
Why is the Cmdlet binding needed? Btw love your videos, you present things so well!
@NTFAQGuy
@NTFAQGuy 2 года назад
Bunch of things including letting you leverage verbose etc parameters
@luizzurobski4462
@luizzurobski4462 Год назад
ty
@robertleist771
@robertleist771 3 года назад
How about how to catch errors in a try block for commands being executed in a PowerShell remote session?
@alexpetrenko5952
@alexpetrenko5952 3 года назад
Hi, it was interesting! However, you did not mention how to get that full error code that you used in 'catch'. Or did I missed that?
@NTFAQGuy
@NTFAQGuy 3 года назад
It’s in the sample file linked in description if I’m following.
@michaellerch
@michaellerch 3 года назад
I didn't know that visual studio code had a Light Mode :)
@NTFAQGuy
@NTFAQGuy 3 года назад
lol. i don't use it normally :-D
@michaellerch
@michaellerch 3 года назад
@@NTFAQGuy Thanks I finished watching the video and it was really helpful! I've done a little with Try / Catch, but the error stuff I didn't even know about. Thanks again!
@NTFAQGuy
@NTFAQGuy 3 года назад
@@michaellerch Glad it was useful!
@jgrote
@jgrote 3 года назад
Powershell VS Code Extension has an "ISE Mode" that makes it look like the old Powershell ISE editor to help ease users of that into vscode. This theme mirrors the look of that app.
@michaellerch
@michaellerch 3 года назад
@@jgrote I heard about that. I was just playing with Visual Studio Code and was trying to figure that out. I'm sure it's a google search away, but I like to stumble around so I know where everything's at and what it does.
@maherriyadh5647
@maherriyadh5647 2 года назад
Hi, i wonder in minute 15:03, in the switch statement there is $number, and in the statement there is $_ . Why didn't you use the variable number instead of $_ ?
@NTFAQGuy
@NTFAQGuy 2 года назад
preference. Code would work if I changed the variable in switch etc.
@ravilobo7977
@ravilobo7977 3 года назад
PowerShell is music. This is like listening to the maestro.
@NTFAQGuy
@NTFAQGuy 3 года назад
Hehe, thank you
@schillaci5590
@schillaci5590 3 года назад
Oh my god he's gone and put the open curley bracket on the wrong line!
@NTFAQGuy
@NTFAQGuy 3 года назад
lol, ahhh that universal debate :-)
@David-wh7rm
@David-wh7rm 3 года назад
@7:22 I've found $($_.Exception.Message) gives better results for me, when using in a write-debug. Great overview though!
@NTFAQGuy
@NTFAQGuy 3 года назад
3 lines up I grab that in a variable but at this point I wanted to show writing out the whole exception :-)
@David-wh7rm
@David-wh7rm 3 года назад
@@NTFAQGuy understood and completely fair enough, I didn't put it in a variable so just thought I'd mention, but I know what you mean 👍
@NTFAQGuy
@NTFAQGuy 3 года назад
@@David-wh7rm All good and agree like the message :-)
Далее
Calling REST with PowerShell
16:05
Просмотров 23 тыс.
PORTAL SPAMMER🤬🤬🤬| Doge Gaming
00:19
Просмотров 2 млн
ЮТУБ БЛОКИРУЮТ?
01:52
Просмотров 896 тыс.
PowerShell Errors and Exceptions Handling
27:49
Просмотров 29 тыс.
Debug PowerShell with and without VS Code
40:57
Просмотров 19 тыс.
PowerShell Remoting
37:12
Просмотров 70 тыс.
I've been using Redis wrong this whole time...
20:53
Просмотров 348 тыс.
PowerShell Master Class - Data and Objects
46:10
Просмотров 25 тыс.