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 [...]
PoshCode Updated for CTP3
I’ve updated the PoshCode script module to support CTP3, and added a -limit parameter to the Get-PoshCode cmdlet so you can specify how many items you want retrieved in the case where there are a lot of matches for your search terms — by default the limit is 25. Improvements to the underlying web search [...]
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 [...]
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, [...]
About_Filter considered Harmful
Someone asked a question in the #PowerShell channel on irc.FreeNode.net today about how to use filters, and pasted this an example like this: filter process-a-m { $_.processname -like "[a-m]*" } Get-Process | where {process-a-m} The question was: why doesn’t this have any output? Well, the answer is: it can’t have any output. The filter [...]