title: Deserialized Object type issues - specifically with Powershell 5 classes and Import-CliXml
body: <p>I'm having issues with Powershell 5 classes and object types when reimporting deserialized objects using the Import-CliXml command.</p>
  
  <p>I have an object of type Computer and I wish to store this as xml and then reimport this next time the script is run</p>
  
  <pre><code>class Computer 
  {
      $Private:hostname
      $Private:ipAddress
  
      Computer([String] $hostname, [String] $ipAddress)
      {
          $this.hostname = $hostname
          $this.ipAddress = $ipAddress
      }
      static [Computer] reserialize([PSObject] $deserializedComputer)
      {
          return [Computer]::new($deserializedComputer.hostname, $deserializedComputer.ipAddress)
      }
  }
  </code></pre>
  
  <p>I export and import the object using the following:</p>
  
  <pre><code>$computer = [Computer]::new("test-machine", "192.168.1.2")
  $computer | Export-CliXml C:\Powershell\exportTest.xml
  $deserializedComputer = Import-CliXml C:\Powershell\exportTest.xml
  </code></pre>
  
  <p>I understand that when this object is reimported that it is deserialized and is basically just a data container (of type [Deserialized.Computer]). I'm trying to figure out how to type check this object before I try and reserialize it using my reserialize method.</p>
  
  <p>For example if I try and cast $deserializedComputer it tells me that:</p>
  
  <pre><code>Cannot convert value "Computer" to type "Computer". Error: "Cannot convert the "Computer" value of type "Deserialized.Computer" to type 
  "Computer"."
  </code></pre>
  
  <p><em>I understand why this can't be casted, I'm just using the error message to point out that the object has knowledge that it's of type [Deserialized.Computer]</em></p>
  
  <p>I can find nothing returned from $deserializedComputer.getMember() that indicates that it is of type [Deserialized.Computer], the only information I can find is that it's of type [PSObject], how can I type check that this object is indeed of type [Deserialized.Computer]? </p>
  
  <p>I should add that type [Deserialized.Computer] doesn't exist at run-time so I can't use this directly in my code, otherwise I would simply use:</p>
  
  <pre><code>$deserializedComputer.getType() -eq [Deserialized.Computer]
  </code></pre>