Reputation: 9429
Is there a resource on how to pass in a Object[]
as a parameter within a PowerShell function?
Both of these functions are cmdlets and they are being exported correctly, but I cannot see the $Return
object in my second function.
Is something like the following needed?
ParameterAttribute.ValueFromPipeline Property (System.Management.Automation)
# Within PowerShell code
$Return = My-Function -Param "value" # $Return is of type Object[]
$ModifiedReturn = My-SecondFunction -Input $Return
Where this is my function definition:
function My-SecondFunction
{
[CmdletBinding()]
Param(
[Parameter(Mandatory=$True)]
[Object[]]$Input
)
begin {}
process
{
Write-Host "test: $Input" # Does not return anything
}
end {}
}
Upvotes: 13
Views: 41421
Reputation: 47792
$Input
is the name of an automatic variable. Use a different name.
I recommend $InputObject
as that is in common usage so it has a well-understood meaning, but usually that means you are accepting pipeline input as well.
Of course if there's a name that's more descriptive for this parameter, you should use that.
Upvotes: 9