title: Remove an attribute from the JSON object in powershell
body: <p>I have following JSON and I would like to remove streets from the JSON object under Address which is an array. I am trying to do this in powershell</p>
  <pre><code>{
    &quot;Customer&quot;: [
      {
        &quot;id&quot;: &quot;123&quot;
      }
    ],
    &quot;Nationality&quot;: [
      {
        &quot;name&quot;: &quot;US&quot;,
        &quot;id&quot;: &quot;456&quot;
      }
    ],
    &quot;address&quot;: [
      {
        &quot;$type&quot;: &quot;Home&quot;,
        &quot;name&quot;: &quot;Houston&quot;,
        &quot;streets&quot;: [
          {
            &quot;name&quot;: &quot;Union&quot;,
            &quot;postalCode&quot;: &quot;10&quot;,
          }
        ]
      },
      {
        &quot;$type&quot;: &quot;Office&quot;,
        &quot;name&quot;: &quot;Hawai&quot;,
        &quot;streets&quot;: [
          {
            &quot;name&quot;: &quot;Rock&quot;,
            &quot;postalCode&quot;: &quot;11&quot;,
          }
        ]
      }
    ],
    &quot;address&quot;: [
      {
        &quot;$type&quot;: &quot;Home1&quot;,
        &quot;name&quot;: &quot;Houston&quot;,
        &quot;streets&quot;: [
          {
            &quot;name&quot;: &quot;Union1&quot;,
            &quot;postalCode&quot;: &quot;14&quot;,
          }
        ]
      },
      {
        &quot;$type&quot;: &quot;Office1&quot;,
        &quot;name&quot;: &quot;Hawaii1&quot;,
        &quot;streets&quot;: [
          {
            &quot;name&quot;: &quot;Rock1&quot;,
            &quot;postalCode&quot;: &quot;15&quot;,
          }
        ]
      }
    ],
  }
  
  </code></pre>
  <p>I would like to remove streets from the JSON object and here is my powershell script but it is not working! I am trying to convert JSON into object and then loop over properties to remove those.</p>
  <pre><code>$FileContent = Get-Content -Path &quot;Test.json&quot; -Raw | ConvertFrom-Json
  foreach ($content in $FileContent) {
      #Write-Host $content.address
      $content.address = $content.address | Select-Object * -ExcludeProperty streets
  }
  
  $FileContent | ConvertTo-Json -Depth 100 | Out-File &quot;Test.json&quot; -Force
  
  </code></pre>