Functions vs Filters

In my previous entry, I referred to Rsbohn’s blog PowerShell $Profile and his function to slow down output

function slowly ($tempo=100) { process { $_; Start-Sleep -milliseconds $tempo}}

This is a good candidate for a FILTER. A filter is function that just has a process scriptblock. So you could have written his as:

filter slowly ($tempo=100) { $_; Start-Sleep -milliseconds $tempo}

Enjoy!

Jeffrey Snover [MSFT]
Windows PowerShell/MMC Architect
Visit the Windows PowerShell Team blog at: http://blogs.msdn.com/PowerShell
Visit the Windows PowerShell ScriptCenter at: http://www.microsoft.com/technet/scriptcenter/hubs/msh.mspx