title: Powershell check if variable is an object
body: <p>[Edit after both answers said lack of clarity]
  My Goal: Perform different operations depending if what is passed to a function is an "object" type thing (e.g. an array, a hashtable) or just a simple "string" type thing. If it's just a string, I'll simply include it in the body of the email. If it's an array or hashtable, I need to do a bunch of processing on it to convert it into an HTML table.</p>
  
  <p>[Original Question Text]
  I'm passing a variable <code>$body</code> to a function <code>Email-Report</code> that can either be a simple string or an object (e.g. a hashtable or array).
  I want to check if <code>$body</code> is an object and do different things depending.
  My problem is <code>$body</code> could be almost anything, not just a string or a hashtable. So I can't just check if <code>$body.GetType().Name -eq String</code></p>
  
  <p>I've tried <code>$body.GetType().Name</code> which returns </p>
  
  <pre><code>IsPublic IsSerial Name                                     BaseType
  -------- -------- ----                                     --------
  True     True     Hashtable                                System.Object
  </code></pre>
  
  <p>However if the variable is an array <code>BaseType</code> becomes <code>System.Array</code> so I can't filter on that property, also as mentioned above the <code>$body</code> variable may not always be a hashtable or an array.
  If it's a hash table, <code>$var.GetType()</code> returns a BaseType of <code>System.Object</code>, however I can't seem to refer to the BaseType property.
  <code>($hash.GetType()).BaseType</code> returns another object itself, which itself has a BaseType property which is blank.</p>
  
  <p>I've also tried <code>$body.IsObject</code> and <code>$body.IsObject()</code> but those methods don't seem to exist. I've also tried <code>$body -eq [System.Object]</code> which I expected to be <code>$true</code>, but it returns <code>$false</code>.</p>
  
  <p>Not sure where to go from here - I think I'm missing something obvious or having a logic error.</p>