title: How do I pass DateTime as a parameter in PowerShell?
body: <p>I have a script that's calling another script and passing in parameters along with it. Whenever I try to pass in a datetime, parts of the datetime are used as arguments for the other parameters. </p>
  
  <h3>script1.ps1</h3>
  
  <pre><code>$dateEnd = Get-Date "12/31/14"
  $siteUrl = "http://foo.com"
  $outputPath = "c:\myFolder"
  
  $argumentList = "-file .\script2.ps1", "test1", $dateEnd, $siteUrl, $outputPath
  Start-Process powershell.exe -ArgumentList $argumentList
  </code></pre>
  
  <h3>script2.ps1</h3>
  
  <pre><code>param
  (
       [string]$test1,
       [DateTime]$dateEnd,
       [string]$siteUrl,
       [string]$outputFile
  )      
  
  $test1
  $dateEnd
  $siteUrl
  $outputFile
  
  Read-Host -Prompt "Press Enter to exit"
  </code></pre>
  
  <p>This would result in:</p>
  
  <pre><code>test1
  Wednesday, December 31, 2014 12:00:00 AM
  00:00:00
  http://foo.com
  </code></pre>
  
  <p>EDIT - string as date, typo on my part:</p>
  
  <p>If I pass the string <code>12/31/14</code> it works fine, but I'd like to be able to pass a date.</p>