Another common parameter you might want to include in your PowerShell code is -ErrorVariable. Like -OutVariable that I talked about yesterday, you can redirect error information to a specified variable:gwmi win32_operatingsystem -errorvariable oops |out-null
Category: Windows PowerShell
Profiles, Snapins, and Consoles
We recently spent a lot of time around the office discussing profiles in Windows PowerShell. Actually, to be more specific, we were discussing snap-ins, those DLLs that bring new and wonderful cmdlets to your PowerShell environment.
"Out, out damn variable"
Ok, maybe I’m not Lady Macbeth dealing with a guilty conscience but there are times I have to get things out of my system, like information via PowerShell. Often I want to store the results of a cmdlet in a variable for additional processing. Usually I do something like this:$myProcesses=get-processAn alternative is to use one of the common paramaters, -OutVariable.
Make-A-Cmdlet: Part 6, Wrapup
Okay, in my cmdlet code, you’ll notice that I used WMI – albeit in a very .NET-esque fashion – to ping a remote computer. That’s kind of my VBScript background talking; WMI is how I’d do the same task in VBScript. Well, it pays to investigate: Turns out .NET has a built-in functioning for pinging computers! I can change my …
I can define that function in 1 step
If you are like me, you’re starting to develop a lot of aliases and custom functions. The thing is, I can’t always remember what every function or alias does. Fortunately, that is pretty easy to discover.
Make-A-Cmdlet: Part 5, More Fixes
So my cmdlet still isn’t working. This time, I’ve made another “debugging” change to my code, adding this line:
PowerQuest – code is online
The folks at CodePlex got me all fixed up: www.codeplex.com/powerquest now has the v0.1 source code and the release binaries, along with documentation for installing and playing the game. If you set up a CodePlex account for yourself you can also post to the forums there, which will be used solely to discuss the game. You can *download* the source …
VBScript and PowerShell Training – Registration Open
Registration is now open for classes in Atlanta, Dallas, Philadelphia, and Omaha. These cities will all host a two-day class on Windows PowerShell this year; you’ll find complete details and registration forms at www.ScriptingTraining.com/classes.asp. We do offer early-bird discounts and space is limited, so if you’re planning to attend, we encourage you to register sooner rather than later….
PowerQuest Finds a Home on the Web
PowerQuest (you know, my new hobby of making Windows PowerShell less productive by making a game snap-in) has found a home on Microsoft’s CodePlex. Since this really is just a hobby, I wanted to be able to share the source code and everything, and CodePlex is all set up to do that. Well, mostly; I have the current binary DLL posted …
Windows PowerShell TFM AVAILABLE
Finally!!!! Amazon has Windows PowerShell TFM available and shows that it is shipping. Hopefully there won’t be too much of a delay in fulfilling the pre-orders. We hope you’ll post your comments and feedback on Amazon. We appreciate all your patience in bringing this baby into the world.
By the way, don’t forget you can also get a copy of …