title: PowerShell 5 passing Datetime parameters in
body: <p>Running the following ps1 but the datetime parameter is resuting in an error.</p>
  
  <p>Debug shows the date is correct ($earlydate = the date I entered)  </p>
  
  <p>The HostIP parameter is being passed so it seems there is a special trick necessary for passing the datetime that I don't know.  </p>
  
  <p>The error I receive is: </p>
  
  <blockquote>
    <p>Cannot validate argument on parameter 'After'. The argument is null or
    empty. Provide an argument that is not null or empty, and then try the
    command again.</p>
  </blockquote>
  
  <p>Any help is greatly appreciated.</p>
  
  <pre><code>param( 
      [Parameter(Mandatory=$True)] 
      [string]$HostIP,
  
      [Parameter(Mandatory=$True)]
      [datetime]$earlydate,
  
      [Parameter(Mandatory=$True)]
      [datetime]$latedate
  )
  
  Invoke-Command {Get-EventLog Security -After $earlydate -Before $latedate} -ComputerName $HostIP | 
  Export-Csv c:\Events\$HostIP.csv
  </code></pre>