Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

ConvertTo-Json does not convert additional members of nested properties #19185

Copy link
Copy link
@JTDotNet

Description

@JTDotNet
Issue body actions

Prerequisites

Steps to reproduce

I am attempting to add a NoteProperty to a reference type property of an object, then convert that entire object to JSON using the ConvertTo-Json cmdlet. While this works fine when adding a NoteProperty to a top level object, if you do this to an object that's a property of the top-level object, the NoteProperty is not handled by the cmdlet:

`$foo = Get-ADUser "someUser"

$foo.SID | Add-Member -MemberType NoteProperty -Name "bar" -Value "barValue" -Force

$foo | ConvertTo-Json`

Expected behavior

Cmdlet should output:

{
  ...
  "SID": {
    "BinaryLength": 28,
    "AccountDomainSid": {
      "BinaryLength": 24,
      "AccountDomainSid": [redacted],
      "Value": [redacted]
    },
    "Value": [redacted],
    "bar": "barValue"
  },
  ...
}

Actual behavior

Output does not include additional property:

{
  ...
  "SID": {
    "BinaryLength": 28,
    "AccountDomainSid": {
      "BinaryLength": 24,
      "AccountDomainSid": [redacted],
      "Value": [redacted]
    },
    "Value": [redacted]
  },
  ...
}

Error details

No response

Environment data

Name                           Value
----                           -----
PSVersion                      7.3.2
PSEdition                      Core
GitCommitId                    7.3.2
OS                             Microsoft Windows 10.0.19044
Platform                       Win32NT
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0

Visuals

No response

Reactions are currently unavailable

Metadata

Metadata

Assignees

No one assigned

    Labels

    Resolution-No ActivityIssue has had no activity for 6 months or moreIssue has had no activity for 6 months or moreWG-Cmdlets-Utilitycmdlets in the Microsoft.PowerShell.Utility modulecmdlets in the Microsoft.PowerShell.Utility module

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      Morty Proxy This is a proxified and sanitized view of the page, visit original site.