title: Parsing a Powershell exported password in C# .NET
body: <p>I have an XML file containing an encrypted version of a username and password. We use this for our powershell scripts. Now instead of using a different method for keeping username and password, I'd like my .NET applications to use this XML file as well.</p>
  
  <p>This is the Powershell code:</p>
  
  <pre><code>$cred = Get-Credential -UserName "myusername" -Message "Credentials"
  $cred | Export-CliXml "C:\Users\degruy43\documents\myencryptedcredentials.xml"
  </code></pre>
  
  <p>The format of the XML file is this:</p>
  
  <pre><code>&lt;Objs Version="1.1.0.1" xmlns="http://schemas.microsoft.com/powershell/2004/04"&gt;
    &lt;Obj RefId="0"&gt;
      &lt;TN RefId="0"&gt;
        &lt;T&gt;System.Management.Automation.PSCredential&lt;/T&gt;
        &lt;T&gt;System.Object&lt;/T&gt;
      &lt;/TN&gt;
      &lt;ToString&gt;System.Management.Automation.PSCredential&lt;/ToString&gt;
      &lt;Props&gt;
        &lt;S N="UserName"&gt;myusername@domain.com&lt;/S&gt;
        &lt;SS N="Password"&gt;01000000d08c9ddf0115d1118c7a00c04fc297eb01000000a144ed33923dc84c8ba21f593965ed7c00000000020000000000106600000001000020000000eec6eedf19e08e2197b866b2a7ef35f7649252ca7d53be654647e9c7bb1e2442000000000e8000000002000020000000e0016da2a4c0155eb4f31b722c7fb319d6b5a2c0bc8faf23c43797bf099c840520000000ebedc8ebdee117b24f5edd53cf2d6cc50259c07ee221281eb1858412121818e340000000e3c3163194b70f687bb6c1011b47a6b95291f9cc9aae4d121935ccbec73c578a452e3a4d70a9356cf5a44232cbf479ae6dc3aa2a37fada50f09826280324f65b&lt;/SS&gt;
      &lt;/Props&gt;
    &lt;/Obj&gt;
  &lt;/Objs&gt;
  </code></pre>
  
  <p>So how can I use this file to build my secure string in .NET? I suppose that this IS the secure string?</p>