A few days ago I went over the PowerShell oneliner from SAPIEN’s March ’09 newsletter. I suggested using it in a scriptblock to save typing. Another possibility is to turn it into a function. Even better would be a function that accepts pipelined input. This would permit me to pipe in a list of folder names and get a usage object for each one. Here’s how it works.
Tag: scriptblock
March PowerShell Oneliner
In this month’s SAPIEN newsletter I offered a PowerShell oneliner to returns usage information for a specified folder. I don’t have room in the newsletter to go into detail so here is more in-depth coverage of this oneliner. I’ll also have a downlink link at the end.
More fun with Microsoft Word and PowerShell
I needed a demonstration for one of my last online PowerShell classes on using COM objects in PowerShell. I took an old VBScript that used Microsoft Word to get document statistics such as word and page count and transformed it into PowerShell. I quickly realized I could flesh out the demo into a larger function that I can actually use. Given that I generate a lot of Word docs, being able to get some document statistics is helpful. So I created a function called Get-DocStatistic.
Scriptblocks as Cmdlet Parameter Values
Jeffrey Snover explains how scriptblocks can become the value for ANY cmdlet parameter. http://blogs.msdn.com/powershell/archive/2008/04/21/mindwarpingpower-cmdlets-scriptblock-parameters.aspx#comments