{"id":8411,"date":"2007-03-04T00:13:02","date_gmt":"2007-03-04T00:13:02","guid":{"rendered":"https:\/\/blogs.msdn.microsoft.com\/powershell\/2007\/03\/04\/functions-vs-filters\/"},"modified":"2019-02-18T13:16:52","modified_gmt":"2019-02-18T20:16:52","slug":"functions-vs-filters","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/powershell\/functions-vs-filters\/","title":{"rendered":"Functions vs Filters"},"content":{"rendered":"<p>In my previous entry, I referred to Rsbohn&#8217;s blog  <a href=\"http:\/\/fundamental.antville.org\/stories\/1585259\/\">PowerShell $Profile<\/a> and his function to slow down output\n<\/p>\n<p><span style=\"color:black;font-family:Courier New;font-size:10pt\">function slowly ($tempo=100) {  process { $_; Start-Sleep -milliseconds $tempo}}<br \/><\/span>\n\t<\/p>\n<p>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:\n<\/p>\n<p><span style=\"color:black;font-family:Courier New;font-size:10pt\">filter slowly ($tempo=100) { $_; Start-Sleep -milliseconds $tempo}<br \/><\/span>\n\t<\/p>\n<p>Enjoy!\n<\/p>\n<p>Jeffrey Snover [MSFT]<br \/>Windows PowerShell\/MMC Architect<br \/>Visit the Windows PowerShell Team blog at:    <a href=\"http:\/\/blogs.msdn.com\/PowerShell\">http:\/\/blogs.msdn.com\/PowerShell<\/a><br \/>Visit the Windows PowerShell ScriptCenter at:  <a href=\"http:\/\/www.microsoft.com\/technet\/scriptcenter\/hubs\/msh.mspx\">http:\/\/www.microsoft.com\/technet\/scriptcenter\/hubs\/msh.mspx<\/a>\n\t<\/p>\n","protected":false},"excerpt":{"rendered":"<p>In my previous entry, I referred to Rsbohn&#8217;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 [&hellip;]<\/p>\n","protected":false},"author":600,"featured_media":13641,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[1],"tags":[],"class_list":["post-8411","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-powershell"],"acf":[],"blog_post_summary":"<p>In my previous entry, I referred to Rsbohn&#8217;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 [&hellip;]<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/powershell\/wp-json\/wp\/v2\/posts\/8411","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/devblogs.microsoft.com\/powershell\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/devblogs.microsoft.com\/powershell\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/powershell\/wp-json\/wp\/v2\/users\/600"}],"replies":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/powershell\/wp-json\/wp\/v2\/comments?post=8411"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/powershell\/wp-json\/wp\/v2\/posts\/8411\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/powershell\/wp-json\/wp\/v2\/media\/13641"}],"wp:attachment":[{"href":"https:\/\/devblogs.microsoft.com\/powershell\/wp-json\/wp\/v2\/media?parent=8411"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/powershell\/wp-json\/wp\/v2\/categories?post=8411"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/powershell\/wp-json\/wp\/v2\/tags?post=8411"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}