Showing archive results for March 2010

Mar 11, 2010
Post comments count0
Post likes count0

Hey, Scripting Guy! How Can I Use Try/Catch/Finally in Windows PowerShell?

ScriptingGuy1

  Hey, Scripting Guy! One thing I miss in Windows PowerShell is the ability to use a Try/Catch/Finally block that I can use in C#. To me it is an elegant solution to error handling. You attempt something, catch any resulting errors, and clean up the mess you made. Are there any plans in Windows PowerShell 3.0 to introduce this kind of str...

Scripting Guy!Windows PowerShellscripting techniques
Mar 10, 2010
Post comments count0
Post likes count0

Hey, Scripting Guy! How Can I Use the Test-Path Cmdlet to Check for Resources?

ScriptingGuy1

  Hey, Scripting Guy! Ignoring errors or bubbling up errors to the user of a script seems a bit inefficient. I mean, wouldn’t it be better to avoid the errors in the first place? I am only a beginner when it comes to writing scripts, and maybe I just do not get it, but why can’t you just write code that does not generate errors?-- ...

Scripting Guy!Windows PowerShellscripting techniques
Mar 9, 2010
Post comments count0
Post likes count0

Hey, Scripting Guy! How Can I Use the –ErrorAction Preference Parameter?

ScriptingGuy1

  Hey, Scripting Guy! I enjoyed reading your blog post yesterday about using $ErrorActionPreference to control the behavior of a script. One thing I never liked about using “On Error Resume Next” from VBScript was that it seemed to be an all-or-nothing type of proposition. There are certain errors I do not need to see, but the...

Scripting Guy!Windows PowerShellscripting techniques
Mar 8, 2010
Post comments count0
Post likes count1

Hey, Scripting Guy! How Can I Use $ErrorActionPreference to Control Cmdlet Handling of Errors?

ScriptingGuy1

   Hey, Scripting Guy! One thing I liked about using VBScript is that I could add On Error Resume Next to the top of a script, and all my problems with the script went away. It was like magic, and I used it to fix many of my scripts. I really miss this capability in Windows PowerShell. -- MW Hello MW, Microsoft Scripting Guy Ed Wilso...

Scripting Guy!Windows PowerShellscripting techniques
Mar 7, 2010
Post comments count0
Post likes count0

Hey, Scripting Guy! Weekend Scripter: Fibonnaci Sequence This!

ScriptingGuy1

Microsoft Scripting Guy Ed Wilson here, it is warming up a bit down here in Charlotte, North Carolina in the United States, and therefore I tend to gravitate outside on weekends. At least, far enough outside to make it to my woodworking shop. Today, I was thinking about building a series of boxes. One of the golden rules in box design is the so-cal...

Scripting Guy!Windows PowerShellscripting techniques