title: Unable to remove item from hash table
body: <p>In Powershell, I have a hash table that contains data similar to this -</p>
  
  <pre><code>Name                   Value                                           
  ----                   -----                                           
  1-update.bat           1                                               
  2-update.bat           2                                               
  3-update.bat           3                                               
  3.1-update.bat         3.1                                             
  4-update.bat           4    
  </code></pre>
  
  <p>I also have an variable that contians a number, for example <code>3</code></p>
  
  <p>What I would like to do is loop through the array and remove any entry where the value is less than or equal to <code>3</code></p>
  
  <p>I'm thinking that this will be easy, especially as <a href="https://technet.microsoft.com/en-us/library/ee692803.aspx" rel="nofollow noreferrer">the docs</a> say that has tables contain a <code>.remove</code> method.  However, the code I have below fails, yeilding this error -</p>
  
  <blockquote>
    <p>Exception calling "Remove" with "1" argument(s): "Collection was of a
    fixed size."</p>
  </blockquote>
  
  <p>Here is the code that I used -</p>
  
  <pre><code>$versions = @{}
  $updateFiles | ForEach-Object {
      $versions.Add($_.name, [decimal]($_.name -split '-')[0])
  }
  
  [decimal]$lastUpdate = Get-Content $directory\$updatesFile
  
  $versions | ForEach-Object {
      if ( $_.Value -le $lastUpdate ) {
          $versions.Remove($version.Name)
      }
  }
  </code></pre>
  
  <p>I first tried to loop <code>$versions</code> in a different manner, trying both the <code>foreach</code> and <code>for</code> approaches, but both failed in the same manner.</p>
  
  <p>I also tried to create a temporary array to hold the name of the versions to remove, and then looping that array to remove them, but that also failed.</p>
  
  <p>Next I hit Google, and while I can find several similar questions, none that answer my specific question.  Mostly they suggest using a list (<code>New-Object System.Collections.Generic.List[System.Object]</code>), whcih from what I can tell is of no help to me here.</p>
  
  <p>Is anyone able to suggest a fix?</p>