Category Archives: Effective PowerShell

Effective PowerShell Item 16: Dealing with Errors

There are several facets to the subject of errors in PowerShell that you should understand to get the most out of PowerShell.  Some of these facets are error handling, error related global variables and error related preference variables.  But the … Continue reading

Posted in Effective PowerShell | 9 Comments

Effective PowerShell Item 15: Using the Output Field Separator $OFS

$OFS is the “output field separator” variable.  Whatever value it contains will be used as the string separator between elements of an array that is rendered to a string.  For example, consider the following array definition and subsequent rendering to … Continue reading

Posted in Effective PowerShell | Leave a comment

Effective Windows PowerShell: The Free eBook

I’ve gotten some requests to turn my Effective PowerShell blog posts into booklet form which I have done.  I expect that this document will grow over time as I add new items.  If you have feedback (typos, suggestions, etc) please … Continue reading

Posted in Effective PowerShell | 19 Comments

Effective PowerShell Item 14: Capturing All Output from a Script

Both version 1 and version 2 of Windows PowerShell have a nasty limitation when it comes to capturing *all* output from a script.  First up, within a script there is no way to redirect host (Write-Host), verbose, warning and debug … Continue reading

Posted in Effective PowerShell | 13 Comments

Effective PowerShell Item 13: Comparing Arrays in Windows PowerShell

PowerShell has a lot of useful operators such as -contains which tests if an array contains an particular element.  But as far as I can tell PowerShell doesn’t "seem" to provide an easy way to test if two array’s contents … Continue reading

Posted in Effective PowerShell | 6 Comments

Effective PowerShell Item 12: Understanding ByValue Pipeline Bound Parameters

In item 11, I covered ByPropertyName pipeline bound parameters.  In this post, I’ll cover the other variety of pipeline binding – ByValue.  ByValue binding takes the input object itself and attempts to bind it by type using type coercion if … Continue reading

Posted in Effective PowerShell | 6 Comments

Effective PowerShell Item 11: Understanding ByPropertyName Pipeline Bound Parameters

Everybody likes to be efficient, right?  I mean we all generally like to solve a problem in an efficient way.  In PowerShell that usually culminates in a "one-liner".  Honestly for pedagogical purposes I find it better much better to expand … Continue reading

Posted in Effective PowerShell | 3 Comments

Effective PowerShell Item 10: Understanding PowerShell Parsing Modes

The way PowerShell parses commands can be surprising especially to those that are used to shells with more simplistic parsing like CMD.EXE.  Parsing in PowerShell is a bit different because PowerShell needs to work well as both an interactive command … Continue reading

Posted in Effective PowerShell | 12 Comments

Effective PowerShell Item 9: Regular Expressions – One of the Power Tools in PowerShell

Windows PowerShell is based on the .NET Framework.  That is, it is built using the .NET Framework and it exposes the .NET Framework to the user.  One very nice feature of the .NET Framework is the Regex class in the System.Text.RegularExpressions namespace.  … Continue reading

Posted in Effective PowerShell | 2 Comments

Effective PowerShell Item 8: Output Cardinality – Scalars, Collections and Empty Sets – Oh My!

In the last post Effective Powershell Item 7: Understanding "Output", we covered a lot about PowerShell output.  However there is a bit more you need to understand to use PowerShell effectively.  This post concerns the cardinality of PowerShell output.  That … Continue reading

Posted in Effective PowerShell | 9 Comments