Powershell: Storing data
<p>I would appreciate if someone could help me with fundamental ways to store data in a tabulated manner in PowerShell, specifically how to add values to a previously created table.</p>

<p>I'd also appreciate if someone could show a code example of the best way to do this kind of thing.</p>

<p>Apologies in advance if this is too fundamental for this arena. I would appreciate being pointed in a useful direction.</p>

<p>Basically, I want to store a collection of plaintext user names and passwords. Nothing fancy so I don't need encryption (I know about the <strong>PSCredential</strong> object. It's not required)</p>

<p><strong>Method 1 - Custom Object</strong></p>

<pre><code>$account = New-Object -TypeName PSObject

Add-Member -InputObject $PRCGuest -MemberType NoteProperty `
    -Name UserName -Value ""

Add-Member -InputObject $PRCGuest -MemberType NoteProperty `
    -Name Password -Value ""
</code></pre>

<p>I know how to assign initial values to this objects members...</p>

<pre><code>$account.UserName = "jimbo"
$account.Password = "1234
</code></pre>

<p>but what is the correct syntax to add further values and is creating an object like this to store lists of data correct?</p>

<p><strong>Method 2 - Hash table</strong></p>

<pre><code>$account = @{
             "jimbo" = "1234";
             "jimmy" = "2346"
}
</code></pre>

<p>I've read that you can create a hashtable and then copy the value pairs into a custom object. How is this done and why do you need this intermediate step?</p>

<p>Finally, are there any good books, ideally language agnostic (as I will be learning C++ soon) that show how to efficiently store tables of data in high level object oriented languages.</p>

<p>Thanks for any help.</p>