March 4th, 2007

Functions vs Filters

PowerShell Team
PowerShell Team

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

Category
PowerShell

Author

PowerShell Team
PowerShell Team

PowerShell is a task-based command-line shell and scripting language built on .NET. PowerShell helps system administrators and power-users rapidly automate tasks that manage operating systems (Linux, macOS, and Windows) and processes.

0 comments

Discussion are closed.