# encoding: ascii
# api: powershell
# title: Invoke-ScriptBlock.ps1
# description: From Windows PowerShell Cookbook (O’Reilly) by Lee Holmes
# version: 0.1
# type: script
# author: Lee Holmes
# license: CC0
# x-poshcode-id: 2185
# x-archived: 2016-05-17T10:50:10
# x-published: 2011-09-09T21:41:00
#
#
##############################################################################
##
## Invoke-ScriptBlock
##
## From Windows PowerShell, The Definitive Guide (O'Reilly)
## by Lee Holmes (http://www.leeholmes.com/guide)
##
##############################################################################
<#
.SYNOPSIS
Apply the given mapping command to each element of the input. (Note that
PowerShell includes this command natively, and calls it Foreach-Object)
.EXAMPLE
1,2,3 | Invoke-ScriptBlock { $_ * 2 }
#>
param(
## The scriptblock to apply to each incoming element
[ScriptBlock] $MapCommand
)
begin
{
Set-StrictMode -Version Latest
}
process
{
& $mapCommand
}