< Back
Convert-Map
Post
NAME Convert-Map
SYNOPSIS
Perform functional-style operations on each element of a sequence or stream of objects in a Powershell pipeline
SYNTAX
Convert-Map [-Expression] <ScriptBlock> [-InputObject] <Object[]> [<CommonParameters>]
DESCRIPTION
Apply the given ScriptBlock expression to each member of the pipelined InputObject.
PARAMETERS
-Expression <ScriptBlock>
The anonymous (in-place) or named (as variable) single-argument lambda function to be applied to each
InputObject element. This must have a single-argument parameter block.
Required? true
Position? 1
Default value
Accept pipeline input? false
Accept wildcard characters? false
-InputObject <Object[]>
The sequence or stream of Objects from the Powershell pipeline.
Required? true
Position? 2
Default value
Accept pipeline input? true (ByValue)
Accept wildcard characters? false
<CommonParameters>
This cmdlet supports the common parameters: Verbose, Debug,
ErrorAction, ErrorVariable, WarningAction, WarningVariable,
OutBuffer, PipelineVariable, and OutVariable. For more information, see
about_CommonParameters (https:/go.microsoft.com/fwlink/?LinkID=113216).
INPUTS
OUTPUTS
-------------------------- EXAMPLE 1 --------------------------
PS C:\\># Double each element of a list.
@(1,2,3) | Convert-Map { param($it) 2 * $it }
2
4
6
-------------------------- EXAMPLE 2 --------------------------
PS C:\\># First double each element of a list and then add 3 to each element of the new list.
@(1,2,3) | Convert-Map { param($it) 2 * $it } | Convert-Map { param($doubled) $doubled + 3 }
5
7
9
RELATED LINKS
SYNOPSIS
Perform functional-style operations on each element of a sequence or stream of objects in a Powershell pipeline
SYNTAX
Convert-Map [-Expression] <ScriptBlock> [-InputObject] <Object[]> [<CommonParameters>]
DESCRIPTION
Apply the given ScriptBlock expression to each member of the pipelined InputObject.
PARAMETERS
-Expression <ScriptBlock>
The anonymous (in-place) or named (as variable) single-argument lambda function to be applied to each
InputObject element. This must have a single-argument parameter block.
Required? true
Position? 1
Default value
Accept pipeline input? false
Accept wildcard characters? false
-InputObject <Object[]>
The sequence or stream of Objects from the Powershell pipeline.
Required? true
Position? 2
Default value
Accept pipeline input? true (ByValue)
Accept wildcard characters? false
<CommonParameters>
This cmdlet supports the common parameters: Verbose, Debug,
ErrorAction, ErrorVariable, WarningAction, WarningVariable,
OutBuffer, PipelineVariable, and OutVariable. For more information, see
about_CommonParameters (https:/go.microsoft.com/fwlink/?LinkID=113216).
INPUTS
OUTPUTS
-------------------------- EXAMPLE 1 --------------------------
PS C:\\># Double each element of a list.
@(1,2,3) | Convert-Map { param($it) 2 * $it }
2
4
6
-------------------------- EXAMPLE 2 --------------------------
PS C:\\># First double each element of a list and then add 3 to each element of the new list.
@(1,2,3) | Convert-Map { param($it) 2 * $it } | Convert-Map { param($doubled) $doubled + 3 }
5
7
9
RELATED LINKS