Converting date strings in PowerShell

Thursday, April 14, 2011

The Get-Date cmdlet lets us create, convert, and format date strings to DateTime .NET objects. However, there’s one thing it cannot do, convert a date string which is not a format it expects (defines by your system locale). For example, if your current culture is en-US you can pass a date string in the format of MM/dd/yyyy to the –Date parameter and Get-date will convert it to a DateTime object: PS > Get-Date -Date 4/13/2011 Wednesday, April 13, 2011 12:00:00 AM   On the other hand, if we pass a string in the format of...
13 comments