You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
# Create and import a sample cmdlet that requires [byte[]] inputAdd-Type@'using System.Management.Automation;[Cmdlet("Get", "Foo")]public class GetFooCommand : PSCmdlet{ [Parameter(Mandatory=true,ValueFromPipeline=true)] public byte[] InputObject; protected override void ProcessRecord() { }}'@-PassThru |ForEach-Object Assembly |Import-Module# Create two instances of a large byte array, one without and# one with a [psobject] wrapper$byteArrayUnwrapped= [byte[]]::new(64mb)
$byteArrayWrapped=New-Object byte[] 64mb# equivalent, but with implicit [psobject] wrapper'--- unwrapped'Get-Foo-InputObject $byteArrayUnwrapped'--- wrapped'Get-Foo-InputObject $byteArrayWrapped# !! Excessively slow.'--- done'
Note that parameter binding via the pipeline is not affected; that is, , $byteArrayWrapped | Get-Foo works as intended (note the need to wrap $byteArrayWrapped in an aux., transitory array via the unary form of , so as to ensure that it is passed as a single object).
Expected behavior
Both calls should return virtually instantly, given that the argument type exactly matches the parameter type and that the cmdlet is otherwise a no-op.
Actual behavior
The second call, due to the invisible [psobject] wrapper resulting from use of New-Object to construct the array, takes an excessive amount of time to complete.
Prerequisites
Steps to reproduce
Note:
Note that parameter binding via the pipeline is not affected; that is,
, $byteArrayWrapped | Get-Fooworks as intended (note the need to wrap$byteArrayWrappedin an aux., transitory array via the unary form of,so as to ensure that it is passed as a single object).Expected behavior
Both calls should return virtually instantly, given that the argument type exactly matches the parameter type and that the cmdlet is otherwise a no-op.
Actual behavior
The second call, due to the invisible
[psobject]wrapper resulting from use ofNew-Objectto construct the array, takes an excessive amount of time to complete.Error details
No response
Environment data
Visuals
No response