Sign In Start Free Trial
Account

Add to playlist

Create a Playlist

Modal Close icon
You need to login to use this feature.
  • Book Overview & Buying Mastering Windows PowerShell Scripting
  • Table Of Contents Toc
Mastering Windows PowerShell Scripting

Mastering Windows PowerShell Scripting

By : Brenton J.W. Blawat
4.4 (16)
close
close
Mastering Windows PowerShell Scripting

Mastering Windows PowerShell Scripting

4.4 (16)
By: Brenton J.W. Blawat

Overview of this book

If you are a system administrator who wants to become an expert in controlling and automating your Windows environment, then this book is for you. Prior knowledge of PowerShell's core elements and applications is required for this book.
Table of Contents (16 chapters)
close
close
15
Index

Error and exception handling – legacy exception handling


When you are developing your scripts, you may run into command-line tools that don't have a built-in exception handling function. This is common for third-party tools that only output the debugging information to the screen, and do not properly handle the exception. One of the most common methods to handle legacy command-based applications is by the use of variables. When you execute a command, you have the ability to check the output from that command. If the output is something other than what you expect, you have the ability to throw an exception.

For example, the netsh command has the ability to add firewall rules to your system. When you successfully add a firewall rule to a system, the response to the console is Ok.. By leveraging a variable, you have the ability to catch the response from this command. If the response is anything other than Ok., you have the ability to write to the console the data contained in the variable.

Tip...

CONTINUE READING
83
Tech Concepts
36
Programming languages
73
Tech Tools
Icon Unlimited access to the largest independent learning library in tech of over 8,000 expert-authored tech books and videos.
Icon Innovative learning tools, including AI book assistants, code context explainers, and text-to-speech.
Icon 50+ new titles added per month and exclusive early access to books as they are being written.
Mastering Windows PowerShell Scripting
notes
bookmark Notes and Bookmarks search Search in title playlist Add to playlist font-size Font size

Change the font size

margin-width Margin width

Change margin width

day-mode Day/Sepia/Night Modes

Change background colour

Close icon Search
Country selected

Close icon Your notes and bookmarks

Confirmation

Modal Close icon
claim successful

Buy this book with your credits?

Modal Close icon
Are you sure you want to buy this book with one of your credits?
Close
YES, BUY

Submit Your Feedback

Modal Close icon
Modal Close icon
Modal Close icon