Quantcast
Viewing all articles
Browse latest Browse all 21975

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

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

Test1.ps1 looks like this:

$mytime =Get-DateWrite-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 21975

Trending Articles



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