Solved

Powershell: error handling with try and catch

Posted on 2012-04-07
5
1,005 Views
Last Modified: 2012-04-17
Anyone know any good resources for error handling in powershell with try, catch, finally ect.  I cant find any Good detailed resources on the subject.  Im pretty sure there are some.

My usual resources are :
hey scripting guy
PluralSight-Training.Net
Don Jones PowerShell (In a month of Sundays)
Powershell in Action

non that i can find go into detail enough to use.
0
Comment
Question by:resolver1
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
5 Comments
 
LVL 20

Assisted Solution

by:BuggyCoder
BuggyCoder earned 100 total points
ID: 37819828
0
 
LVL 69

Accepted Solution

by:
Qlemo earned 400 total points
ID: 37821097
Note regarding the second link: PowerShell 2.0 already has try/catch/finally built-in. trap is hence out-dated, though still useful in some cases.

Additional, up-to-date info is contained in the free eBook Effective Windows PowerShell, p.46ff.

Trap and Error Handling in general is covered again in Mastering PowerShell, Chapter 11 (resp. http://powershell.com/Mastering-PowerShell.pdf, p.326ff).
0
 

Author Closing Comment

by:resolver1
ID: 37827905
Some great free resources. i partilarly like the Mastering PowerShell section on powershell. I use that website but wasnt aware of the free booklet.

Thanks
0
 
LVL 8

Expert Comment

by:Brent Challis
ID: 37854328
if you have installed PowerShell_ISE there is help available that has a section:
about_Try_Catch_Finally, or online at
http://technet.microsoft.com/en-us/library/hh847793.aspx

Which is useful as well.
0
 

Author Comment

by:resolver1
ID: 37854805
Thanks for taking the time to post :-)

I'm not a big fan of microsoft documenation/training on their own products but hey its another resource.
0

Featured Post

Does Powershell have you tied up in knots?

Managing Active Directory does not always have to be complicated.  If you are spending more time trying instead of doing, then it's time to look at something else. For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A recent project that involved parsing Tableau Desktop and Server log files to extract reusable user queries for use in other systems. I chose to use PowerShell to gather the data, and SharePoint to present it...
In previous parts of this Nano Server deployment series, we learned how to create, deploy and configure Nano Server as a Hyper-V host. In this part, we will look for a clustering option. We will create a Hyper-V cluster of 3 Nano Server host nodes w…
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

740 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question