title: Check if a property is a PSCustomObject in PowerShell v3
body: <p>I have an array of PSCustomObject created with several properties on them. Some properties are ints, some strings, and others are what I surmise to be dictionary object (the objects are being returned from Invoke-RestMethod) Here's an example:</p>
  
  <pre><code>&gt; $items[0]
  
  id       : 42
  name     : Modularize the widget for maximum reuse
  priority : {[id, 1], [order, 1], [name, High]}
  project  : {[id, 136], [name, Wicked Awesome Project]}
  </code></pre>
  
  <p>Ultimately, what I want to do is to "flatten" this structure so that I can pipe to to Export-CSV and all the data is retained. Each property would become a column. Example:</p>
  
  <pre><code>id             : 42
  name           : Modularize the widget for maximum reuse
  priority_id    : 1
  priority_order : order
  priority_name  : High
  project_id     : 135
  project_name   : Wicked Awesome Project
  </code></pre>
  
  <p>So, my thought was to enumerate through the properties and if any one is a Dictionary/HashTable/PSCustomObject to enumerate through it's properties and add them the to parent property to flatten this structure out.</p>
  
  <p>However, I have not been able to successfully infer whether or not a property is a Dictionary/HashTable/PSCustomObject. I loop through all the properties like so.</p>
  
  <pre><code> foreach($property in $item.PsObject.Properties)
   {
       Write-Host $property
       Write-Host $property.GetType()
       Write-Host "-------------------------------------------------------------"
  
       # if a PSCustomObject let's flatten this out
       if ($property -eq [PsCustomObject])
       {
          Write-Host "This is a PSCustomObject so we can flatten this out"
       }
       else
       {
          Write-Host "Use the raw value"
       }
  
   }
  </code></pre>
  
  <p>For properties that appear to be PSCustomObject this prints out the following.</p>
  
  <pre><code> System.Management.Automation.PSCustomObject project=@{id=135}
   System.Management.Automation.PSNoteProperty
   -------------------------------------------------------------
  </code></pre>
  
  <p>However, I am unable to to conditionally check that this ia PSCustomObject. All conditionals that I have tried fall under the else condition. I have tried replacing [PSCustomObject] with [Dictionary] and [HashTable]. Note that checking the type won't help since they all appear to be PSNoteProperty.</p>
  
  <p>How can I check that a property is in fact a PSCustomObject and therefore needs to be flattened?</p>