Skip to content

ConvertTo-Json neglects to serialize ETS properties when passed output from CDXML cmdlets (CIM instances) that isn't [psobject] wrapped by argument #24554

Open

Description

Prerequisites

Steps to reproduce

Note:

# Note: Since objects passing through the pipeline are automatically [psobject]-wrapped, the following
#   pipeline alternative works correctly:         
#    Get-PhysicalDisk | ConvertTo-Json 3>$null | ConvertFrom-Json | Format-List
ConvertTo-Json (Get-PhysicalDisk) 3>$null | ConvertFrom-Json | Format-List

Expected behavior

CimClass                         : @{CimSuperClassName=MSFT_StorageFaultDomain; CimSuperClass=; CimClassProperties=System.Object[]; CimClassQualifiers=System.Object[];
                                   CimClassMethods=System.Object[]; CimSystemProperties=}
CimInstanceProperties            : {@{Name=ObjectId; Value={1}\\MKW11\root/Microsoft/Windows/Storage/Providers_v2\SPACES_PhysicalDisk.ObjectId="{47519af7-9162-11ee-9dc0-806e6f6e6963
                                   }:PD:{f2881886-c54b-46f7-c1ac-8eb641e316de}"; CimType=14; Flags=35688452; IsValueModified=False}, @{Name=PassThroughClass; Value=; CimType=14;
                                   Flags=572522500; IsValueModified=False}, @{Name=PassThroughIds; Value=; CimType=14; Flags=572522500; IsValueModified=False},
                                   @{Name=PassThroughNamespace; Value=; CimType=14; Flags=572522500; IsValueModified=False}…}
CimSystemProperties              : @{Namespace=root/microsoft/windows/storage; ServerName=MKW11; ClassName=MSFT_PhysicalDisk; Path=}
ClassName                        : MSFT_PhysicalDisk
Usage                            : Auto-Select
OperationalStatus                : OK
# ... remaining properties omitted for brevity.

Actual behavior

CimClass              : @{CimSuperClassName=MSFT_StorageFaultDomain; CimSuperClass=; CimClassProperties=System.Object[]; CimClassQualifiers=System.Object[];
                        CimClassMethods=System.Object[]; CimSystemProperties=}
CimInstanceProperties : {@{Name=ObjectId; Value={1}\\MKW11\root/Microsoft/Windows/Storage/Providers_v2\SPACES_PhysicalDisk.ObjectId="{47519af7-9162-11ee-9dc0-806e6f6e6963}:PD:{f2881
                        886-c54b-46f7-c1ac-8eb641e316de}"; CimType=14; Flags=35688452; IsValueModified=False}, @{Name=PassThroughClass; Value=; CimType=14; Flags=572522500;
                        IsValueModified=False}, @{Name=PassThroughIds; Value=; CimType=14; Flags=572522500; IsValueModified=False}, @{Name=PassThroughNamespace; Value=; CimType=14;
                        Flags=572522500; IsValueModified=False}…}
CimSystemProperties   : @{Namespace=root/microsoft/windows/storage; ServerName=MKW11; ClassName=MSFT_PhysicalDisk; Path=}

That is, only the type-native properties were serialized, not also the ETS (adapted) ones.

Error details

No response

Environment data

PowerShell 7.5.0-preview.5 on Windows (also affects Windows PowerShell)

Visuals

No response

Activity

  1. added
    Needs-Triage
    on Nov 6, 2024
  2. changed the title [-]`ConvertTo-Json` neglects to serialize ETS properties when passed output from CDXML cmdlets that isn't `[psobject]` wrapped (CIM instances) by argument[/-] [+]`ConvertTo-Json` neglects to serialize ETS properties when passed output from CDXML cmdlets (CIM instances) that isn't `[psobject]` wrapped by argument[/+] on Nov 6, 2024
  3. added
    WG-NeedsReview
    WG-Cmdlets
    on Jul 2, 2025
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

    Needs-TriageWG-CmdletsWG-NeedsReview

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions