Quantcast
Channel: The Official Scripting Guys Forum! forum
Viewing all articles
Browse latest Browse all 15028

Passing DateTime to Powershell Results in 00:00:00 Time

$
0
0

I have 2 basic powershell test scripts (test1.ps1 and test2.ps1)

Test1.ps1 looks like this:

$mytime = Get-Date
Write-Host "Passing in: $mytime"

$myvar = Invoke-Expression "C:\temp\Test2.ps1 -reftime $mytime"


Test2.ps1 looks like this:

param([datetime]$reftime)

Write-Host "Received: $reftime"


When I run Test1.ps1, I receive the messages in the console pane:

Passing in: 06/17/2013 01:32:02
Received: 06/17/2013 00:00:00

Does anyone know why the time is changed to 00:00:00?

Thanks for any help.


Viewing all articles
Browse latest Browse all 15028

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>