title: Why is my powershell script giving an error about a null key not being allowed in a hash literal?
body: <p>I'm new to powershell and trying to create an object based on a class I have made called <em>User</em>.  When I try to pass in arguments when I create it, it complains about null values not being allowed in a hash literal, but every argument has a non-null value from what I can tell.  The error is: <code>A null key is not allowed in a hash literal.</code></p>
  
  <p>If I leave off the <code>-Arguments</code> parameter and <code>echo</code> the object, I get an empty table with no contents, so I think I'm setting up the arguments wrong.</p>
  
  <p>Edit:
  I removed the <code>$</code> from <em>FirstName</em> and <em>LastName</em>, but now I'm getting an error that says, <code>"Cannot find an overload for "User" and the argument count: 1."</code></p>
  
  <p>Edit 2:
  Below is the working code.</p>
  
  <pre><code>class User
  {
      [string]$FirstName = ""
      [string]$LastName = ""
      [string]$UserID = ""
  }
  
  $testUser = New-Object -TypeName User -Property @{FirstName = "John"; LastName = "Smith"; UserID = "abc123"}
  $testUser
  </code></pre>
  
  <p>Below was the incorrect code.</p>
  
  <pre class="lang-bsh prettyprint-override"><code>
  class User
  {
      [string]$FirstName = ""
      [string]$LastName = ""
      [string]$UserID = ""
  }
  
  $testUser = New-Object -TypeName User -Argumentlist @{$FirstName = "John"; $LastName = "Smith"; UserID = "abc123"}
  $testUser
  </code></pre>
  
  <p>I'm expecting an object called <code>$testUser</code> to be created as well as a table with the values I supplied during its creation.  However, I am receiving the aforementioned error message.  When I either remove or comment out everything after <code>-TypeName</code> <em>User</em>, the table I was expecting is output, but it's empty as I did not pass it arguments.</p>