I’m often training administrators to use Windows PowerShell or offering guidance in a number of forums. As you might imagine I see a lot of code samples. Of course I help with the immediate challenge, but often I see opportunities where a few slight tweaks to the code layout can make a difference in readability and troubleshooting. Here’s what I’m talking about.
Tag: powershell
Updated Windows PowerShell:TFM 3rd edition now available
At long last, we’ve released an updated version of Windows PowerShell: TFM 3rd Ed that covers PowerShell CTP 3. Actually, you’ll find some overlap with the version of PowerShell included in WIndows 7 RC1. This version of the book is offered in eBook format as part of our IPO program.
June ’09 PowerShell One-Liner
In case you don’t get the SAPIEN Newsletter, here’s my PowerShell one-liner for the month that uses Get-Command to find scripts in your path.
PowerShell Functions: Return vs Write
The other day I was involved in a short Twitter debate about the relative merits of using RETURN vs Write-Object (or its alias Write) in PowerShell functions. Here’s my take.
Updated PowerShell TreeForm
Not too long ago I wrote a blog post about a Windows Form PowerShell script to display a folder tree. I got some feedback about an error when running the script. The problem was that I was casting a variable in one of the functions to a specific type. Normally this is considered a best practice. But in this situation the [System.Windows.Forms.TreeNode] class depends on the parent class being loaded in your PowerShell session. Even though I thought I had tested thoroughly on PowerShell v1 and v2 I must have missed something and the [System.WIndows.Forms] class was getting loaded into my shell prior to running the script, which is why I never saw the error. Anyway, I’ve since modified the problematic function to remove the type casting.
It slices, it dices, and it makes forms!
Some of you may be familiar with our community version of PrimalForms (available on http://www.primaltools.com). If you are ready to take your PowerShell forms to the next level or want to add forms to your PowerShell scripts for the first time, then PrimalForms 2009 is for you. But wait! Some of you may ask: I […]
Creating XML Configuration Files the PowerShell Way.
Several weeks ago I posted an entry on creating configuration files. This same technique can also work with XML files. I’m still working on a more advanced technique but wanted to share this simpler approach.
Good, Better, Best
I’m very happy to see more and more people getting their hands dirty with Windows PowerShell. A common challenge I see across different support forums is getting information from one part of a script to another. Very often the user has created a function and is attempting to use its output elsewhere in their script. Often I can tell the scripter is coming from a VBScript background or at least thinking that way. There’s nothing necessarily wrong with writing a PowerShell script in a VBScript style, but these scripts are missing out. Let me walk you through several iterations of a function to demonstrate.
PowerShell Special Forces Invades Columbus, Ohio
Are you ready Ohio? We’re bringing our intense, one-of-a-kind Special Forces PowerShell training to Columbus, Ohio July 27-29, 2009. We’re looking for up to 15 recruits who want to learn PowerShell from the ground up and aren’t afraid to get their hands duty. This is unlike any other training course you’ve ever taken. Not everyone can meet the requirements, but those that do learn more PowerShell than they realized was possible in three days. But wait..there’s more!
Can I Get a Little Help Here?
One of my favorite features in PowerShell v2.0 is the ability to add help scripts and functions. The help system with cmdlets is terrific. Type help and the name of a cmdlet and you get syntax, parameters, a description and examples. In PowerShell v2 you can get this same functionality for your scripts and functions. The example I want to show you will work with PowerShell v2.0 that ships with WIndows 7 Release Candidate. There have been some changes since PowerShell CTP3 so if you want the absolute latest PowerShell bits you’ll need Windows 7. Here’s what you can look forward to.