Wednesday, 8 July 2015

How to assign Date variable in Powershell

You can set datetime value to a variable by using Get-Date cmdlet and we can also a convert date string to datetime object using simple DateTime casting.

This assigns the current date time value to the variable $a
$a = Get-Date
Use the below script if you want to get date object from specific date value.
$a = Get-Date "07/06/2015 05:00 AM"
You can also achieve this by using simple DateTime casting
$a = [DateTime] "07/06/2015 05:00 AM"


No comments:

Post a Comment