title: Adding data to Hash Table using Powershell 'Cannot find an overload for "Add" and the argument count"
body: <p>I am teaching myself Powershell, and I am struggling to grasp Hash tables. I get the concept, but applying it is a whole other story. </p>
  
  <p>I am using a 'Hey Scripting Guy' post as reference, <a href="http://blogs.technet.com/b/heyscriptingguy/archive/2011/10/15/automatically-create-a-powershell-hash-table-10-15-11.aspx" rel="nofollow">http://blogs.technet.com/b/heyscriptingguy/archive/2011/10/15/automatically-create-a-powershell-hash-table-10-15-11.aspx</a> , namely this piece right here:</p>
  
  <pre><code>To create a hash table dynamically, follow these steps:
  1.       Create an empty hash table.
  2.       Store the empty hash table in a variable.
  3.       Collect the data.
  4.       Store the collected data in a variable.
  5.       Use the foreach statement to walk through the collected data.
  6.       Inside the loop call the add method to add the key value pairs to the hash table.
  
  An example of this procedure is shown here:
  $hash = $null
  $hash = @{}
  $proc = get-process | Sort-Object -Property name -Unique
  
  foreach ($p in $proc)
  {
   $hash.add($p.name,$p.id)
  }
  </code></pre>
  
  <p>Which works great, however when I try to fit this to my needs, it breaks saying:</p>
  
  <pre><code>Cannot find an overload for "Add" and the argument count: "1".
  At line:15 char:10
  + $hash.add &lt;&lt;&lt;&lt; ($strGroup)
      + CategoryInfo          : NotSpecified: (:) [], MethodException
      + FullyQualifiedErrorId : MethodCountCouldNotFindBest
  </code></pre>
  
  <p>Google turned up nothing relevant, so I turn to you, Stack Overflow Powershell users, what am I doing wrong here?</p>
  
  <pre><code>import-module activedirectory
  $strDate = Get-Date
  $strGroupList = get-content "C:\Users\MYUSERNAME\Documents\Group Audit\audit.txt"
  $strGroupDetails = Get-ADGroupMember -identity $strGroup 
  
  
  $strGroupList #list groups found
  
  $hash= $null #empty the hash table
  $hash = @{} 
  
  
  foreach ($strGroup in $strGroupList)
  {
  $hash.add($strGroup)
  }
  </code></pre>
  
  <p>What I am doing is simply reaching into a text file, grabbing the names of Active Directory groups, returning them (for purposes of stepping through the code), and the intention is to get all members of the groups in the each item in my list (text file), into separate arrays, by Group. For example:</p>
  
  <pre><code>Group1     Time/Date
  ------     ---------------
  member1
  member2
  member3
  member4
  
  Group Owner:__________
  
  Group2     Time/Date
  ------     ----------------
  member1
  member2
  member3
  member4
  
  Group Owner:__________
  </code></pre>
  
  <p>The issue, is that I have no idea what I am doing wrong. I read through the post, did it his way just fine, but am having trouble with my way. I'm sure I fat fingered something, but I just can't find it!</p>
  
  <p>Any help is appreciated, and any criticism is welcome.</p>