PowerShell: Determine your function’s position in the pipeline
I just posted an article to the FAQ on the PoshCode Wiki answering this question that came up again on our IRC PowerShell user group today. It came up in the context of determining whether a function was the last function on the pipeline, because one of our users was looking for a way (other [...]
Using Script Functions in the PowerShell Pipeline ( Take Two )
One of the consistent questions about PowerShell is: what’s the best way to write a script or a function to process pipeline objects and be able to take it’s parameters as a normal function? Of scripts and functions The first thing to know is that in PowerShell, there’s really no difference between a script (just [...]
Ideas for Writing Composable PowerShell scripts
I was just having some fun with some recent blog posts… WPF & PowerShell – Part 5 has a script for “Get-Listbox” and for “Show-Control” and Halr9000 wrote a script he called Get-PSBlogroll I had modified the example from the WPF post to create a listbox which will “start” whatever you double click … Get-Listbox [...]
Pipeline Input vs Parameters in PowerShell scripts
A relatively new PowerShell user came into #PowerShell on IRC.FreeNode.net this week to ask a question about scripts and the pipeline, and the conversation went so well, that I thought I’d share it with you all in case it helps clear things up for you. We’ll call him “user” since he left before I could [...]
Reservoir sampling and performance considerations
I started this post a few weeks ago, but never quite got around to posting it, and then I saw today that Dmitry wrote about the memory problems with using measure-object and I thought this would be a great time to post this. Essentially, this is a continuation of my exploration of development in the [...]
What’s the desired behavior of inputObject?
In response to Kirk Munro’s comment on my Writing Cmdlets for the PowerShell Pipeline post: You know, I’ve looked at your articles about cmdlets/functions in the pipeline and I feel you’re missing something. The purpose of the InputObject parameter is to pass in a collection as a single object. This is as opposed to using [...]
PowerShell 2.0 CTP – Script Cmdlets
Well, the first alpha CTP release of PowerShell 2.0 is out, and there’s a lot of new stuff in it … but I won’t repeat the list from the PowerShell blog, because I’m sure you’ve seen it five or six times already. Instead, lets just skip straight to talking about one of the features we’ve [...]
Writing Cmdlets for the PowerShell Pipeline
In a continuation of what is, sadly, becoming a series on how the PowerShell Pipeline works … Karl Prosser brought to my attention that certain powershell commands which have an -InputObject parameter don’t actually work when you pass something into it … so I thought I should create a cmdlet to show you how to [...]
Writing Better Script Functions for the PowerShell Pipeline
I wrote a post last week about how to write functions for use in the PowerShell pipeline and I’ve been using the template I wrote in that post as the basis for several of my other scripts … and I’ve been gradually fleshing it out, and improving it, so I thought I’d drop it here [...]
Using Script Functions in the PowerShell Pipeline
Update, I created a better version of a pipeline function for powershell … Every once in a while the question of how to best use the process block of a function to process pipeline objects comes up on IRC, and although I’m sure others have already written this up on the web in the past, [...]