Skip to content

Write-Output -NoEnumerate does not work as advertised in PS 6.0-6.2 #3815

@vexx32

Description

@vexx32

Issue Details

See PowerShell/PowerShell#9069 for full details, this is a summary of the issue.

$List = [System.Collections.Generic.List[string]]::new( [string[]]@("test", "one", "two") )
$Output = Write-Output $List -NoEnumerate

# In PS 5.1
$Output.GetType() -eq [System.Collections.Generic.List[string]]

# In PS 6.0-6.2
$Output.GetType() -eq [PSObject[]]

The linked PR fixes the long-standing regression for future PS Versions, though I'm unsure if it'll make the 6.2 release; it should be set for 6.3 if not, though.

Basically, in existing versions of PS Core, Write-Output's -InputObject parameter is typed as PSObject[] which causes the parameter binder to enumerate the entire collection during parameter binding, rendering the -NoEnumerate switch useless as the collection it passes along has already been enumerated.

Versions 6.0-6.2 should be documented as having broken behaviour, as the parameter does not do what is reasonably expected, regressing from Windows PowerShell.

Version(s) of document impacted

  • Impacts 6.next document
  • Impacts 6 document
  • Impacts 5.1 document
  • Impacts 5.0 document
  • Impacts 4.0 document
  • Impacts 3.0 document

Reason(s) for not selecting all version of documents

  • The documented feature was introduced in selected version of PowerShell
  • This issue only shows up in selected version of the document

Metadata

Metadata

Assignees

Labels

Pri0Priority - Highestarea-utilityArea - Microsoft.PowerShell.Utility module

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions