Skip to content

Direct redirection of a custom object ([pscustomobject] instance) to a file with ">" produces no output. #4812

Closed

Description

Even though > is not an actual alias of Out-File, it usually is an effective alias; the two generally behave the same.

However, when outputting a [pscustomobject] instance, > apparently produces an empty file (the file contains only the UTF16-LE BOM and a newline):

Steps to reproduce

# Use Out-File explicitly.
[pscustomobject] @{ one = 1 } | Out-File tmp.txt; Get-Content tmp.txt

'---'

# Use > instead of Out-File, which should produce the same result.
[pscustomobject] @{ one = 1 } > tmp.txt; Get-Content tmp.txt

Expected behavior


one
---
  1

---

one
---
  1

Actual behavior


one
---
  1

---

I.e., using > instead of Out-File resulted in an empty file (just the UTF16-LE BOM and a newline).

Environment data

PowerShell Core v6.0.0-beta.6 on macOS 10.12.6
PowerShell Core v6.0.0-beta.6 on Ubuntu 16.04.3 LTS
PowerShell Core v6.0.0-beta.6 on Microsoft Windows 10 Pro (64-bit; v10.0.15063)
Windows PowerShell v5.1.15063.502 on Microsoft Windows 10 Pro (64-bit; v10.0.15063)

Activity

  1. added a commit that references this issue on Sep 20, 2017
    4c29f57
  2. added a commit that references this issue on Aug 6, 2026
    e3169e5
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Issue-BugIssue has been identified as a bug in the productWG-Languageparser, language semantics

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions