Prerequisites
Steps to reproduce
If you define a class with only hidden properties and an overload to the ToString() method, displaying the object falls back to the ToString() method, as expected.
But a call to Get-Member on such an object, forces a full ETS refresh: the formatter now believes the type has visible members and switches to the list renderer, resulting in blank lines (since actually all members are hidden) instead of the expected ToString().
I found this issue was first noticed in issue #17071 but I just ran into it myself when coding a new class in PowerShell. It's still occurring on PowerShell 7.5.2 .
Code snippet
1. Minimalistic sample class
class CustomClass {
hidden [string] $myString
CustomClass([string] $newVal) { $this.myString = $newVal }
[string] ToString() { return $this.myString }
}
$myObject = [CustomClass]"Test"
# 1. Normal display uses ToString()
$myObject
# 2. Inspect the object
$myObject | Get-Member
# 3. Display again – blank line appears
$myObject
Expected behavior
PS /> $myObject = [CustomClass]"Test"
PS /> $myObject
Test
PS /> $myObject | Get-Member
TypeName: CustomClass
Name MemberType Definition
---- ---------- ----------
Equals Method bool Equals(System.Object obj)
GetHashCode Method int GetHashCode()
GetType Method type GetType()
ToString Method string ToString()
PS /> $myObject
Test
Actual behavior
PS /> $myObject = [CustomClass]"Test"
PS /> $myObject
Test
PS /> $myObject | Get-Member
TypeName: CustomClass
Name MemberType Definition
---- ---------- ----------
Equals Method bool Equals(System.Object obj)
GetHashCode Method int GetHashCode()
GetType Method type GetType()
ToString Method string ToString()
PS /> $myObject
Error details
Environment data
PS /> $PSVersionTable
Name Value
---- -----
PSVersion 7.5.2
PSEdition Core
GitCommitId 7.5.2
OS Darwin 24.6.0 Darwin Kernel Version 24.6.0: Mon Jul 14 11:30:29 PDT 2025; root:xnu-11417.…
Platform Unix
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
WSManStackVersion 3.0
Visuals
No response
Prerequisites
Steps to reproduce
If you define a class with only hidden properties and an overload to the ToString() method, displaying the object falls back to the ToString() method, as expected.
But a call to Get-Member on such an object, forces a full ETS refresh: the formatter now believes the type has visible members and switches to the list renderer, resulting in blank lines (since actually all members are hidden) instead of the expected ToString().
I found this issue was first noticed in issue #17071 but I just ran into it myself when coding a new class in PowerShell. It's still occurring on PowerShell 7.5.2 .
Code snippet
1. Minimalistic sample class
Expected behavior
Actual behavior
Error details
Environment data
Visuals
No response