title: Convert saved PSCustomObject (as string) back to hashtable
body: <p>I have a process parsing out a number of CSV documents and saving changes for later processing in a database. When one row (a person) in any of the CSVs isn't found in the person database, the process saves off that record from the CSV. I currently have it saving as the string output of the hashtable. So CSV document</p>
  
  <pre><code>First,Last,Office
  Joe,Smith,Detroit
  </code></pre>
  
  <p>The output from <code>import-csv "path to my doc.csv"</code> when using the debugger in VS 2015 the string is visualized as:</p>
  
  <pre><code>@{First=Joe; Last=Smith; Office=Detroit;}
  </code></pre>
  
  <p>It also expands out to be a key/value set of:</p>
  
  <pre><code>First  | Joe
  Last   | Smith
  Office | Detroit
  </code></pre>
  
  <p>In powershell, I'm able to just use the names objects in the table as <code>$obj.First</code> and move on with things. But I'm not able to save that string to a database, and bring it back as a usable powershell object. I always end up with the string literal. </p>
  
  <p>Is there a way to convert this string back to a hashtable, or other key/value pair? </p>
  
  <p>I've given this a try: </p>
  
  <pre><code>$data = ConvertFrom-String $raw -PropertyNames First,Last,Office
  </code></pre>
  
  <p>I've tried that on both the raw string as is, which just gives the string back, with the property names in it. I've also converted the original hash to an array:</p>
  
  <pre><code>[string[]]$l_array = $raw | out-string
  </code></pre>
  
  <p>Then when I convert it back using the <code>ConvertFrom-String</code> command, it is actually shifting the data elements and adding the keys, as values. </p>
  
  <p>Thanks for the help. I can provide more details, or sample code as needed. </p>
  
  <p>Edit
  The other side of this, is, how could I store the data that is currently a PSCustomObject, in a better format, that I can rebuild into the same PSCustomObject? I thought perhaps Export-Csv might work, but you can't export to a string. At least as far as I can tell. </p>