Write-Output -NoEnumerate wrap singular items into PSObject[]
See original GitHub issueAs far as I understand, issue caused by #2038.
Steps to reproduce
(Write-Output -NoEnumerate 1).GetType().FullName
(1 | Write-Output -NoEnumerate).GetType().FullName
Expected behavior
System.Int32
System.Int32
Actual behavior
System.Management.Automation.PSObject[]
System.Management.Automation.PSObject[]
Environment data
> $PSVersionTable
Name Value
---- -----
PSVersion 6.0.0-beta.8
PSEdition Core
GitCommitId v6.0.0-beta.8-46-ge3397b63e756bf432bbe80f5e9c4407d52d6b5b9
OS Microsoft Windows 10.0.15063
Platform Win32NT
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0...}
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
WSManStackVersion 3.0
Issue Analytics
- State:
- Created 6 years ago
- Reactions:2
- Comments:15 (6 by maintainers)
Top Results From Across the Web
Write-Output (Microsoft.PowerShell.Utility)
Example 3: Suppress enumeration in output. This command adds the NoEnumerate parameter to treat a collection or array as a single object through...
Read more >Powershell: Write-Output -NoEnumerate not suppressing ...
The NoEnumerate parameter has no effect on collections that were created by wrapping commands in parentheses, because the parentheses force ...
Read more >Write-Output - PowerShell Command - PDQ
The NoEnumerate parameter has no effect on collections that were created by wrapping commands in parentheses, because the parentheses force enumeration.
Read more >Powershell: Everything you wanted to know about arrays
This array has 4 items. When we call the $data variable, we see the list of our items. If it is an array...
Read more >Let's Kill Write-Output
One function of Write-Output is the –NoEnumerate parameter. This allows you pass an array as a single object instead of processing each array ......
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
As for a workaround:
Use
-InputObject
explicitly rather than positional parameter binding:This is a somewhat ironic reversal from Windows PowerShell, where the inverse workaround (omitting
-InputObject
) is required to make-NoEnumerate
behave properly (with input collections).Minimal repros on PSCore 6.2.1: