title: Adding a datetime to a datatable with the current datetime?
body: <p>I'm trying to add a field to a datatable with the current datetime.  I want to add it here so that when I use another piece of code to create the table, it creates it as datetime (add-sqltable, for what it's worth).  </p>
  
  <pre><code>#create the datatable
  $quer = invoke-sqlcmd2 -serverinstance myservername -database "tempdb" -query "select @@servername as servername" -As 'DataTable' 
  #now add the datetime field
  $quer.columns.add("InsDate",[DateTime])
  </code></pre>
  
  <p>At this point I get stuck.  This doesn't work:</p>
  
  <pre><code>$quer | %{$_.InsDate = get-date}
  </code></pre>
  
  <p>I get this error message:</p>
  
  <pre><code>Exception setting "InsDate": "Unable to cast object of type
   'System.Management.Automation.PSObject' to type 'System.IConvertible'.Could
  n't store &lt;2/26/2013 11:26:23 AM&gt; in InsDate Column.  Expected type is DateTime."
  </code></pre>
  
  <p>Changing the format doesn't work either.  Is there some way to do this?  Thanks.</p>