I have the following string: "02-06-2018 16:25:28". I need to convert it to a DateTime object. I tried doing this:
[DateTime]::ParseExact('02-06-2018 16:25:28', 'dd-MM-yyyy hh:mm:ss', $null)
But it did not work:
String was not recognized as a valid DateTime.
Is there another function other than [DateTime]::ParseExact that supports parsing the string in this fomat dd-MM-yyyy hh:mm:ss?
I'm using PowerShell v5.1.