Hi everybody. I have a script that I’ve written with a really kludgy DateTime conversion. It works, but I know it’s wrong.
I have a string that I parse out of a proxy log that looks like this”
Get-Date says it can’t convert it because it’s not a valid DateTime. I save it as variable called $DateTime and then do this:
$DateTime = $DateTime.split(":") + " " + $DateTime.split(":") + ":" + $DateTime.split(":") + ":" + $DateTime.split(":") [DateTime]$DateTime = get-date $DateTime
That works, but there’s got to be a better way to turn the original string into a DateTime object.