How to Convert a String to a Date in PowerShell
To convert a string to a date in PowerShell, cast it with [datetime] when it’s in US or ISO format. For any other layout, use [datetime]::ParseExact() and tell it the exact format: Output: Once it’s a DateTime, you can format it, compare it and do date math with it. I ran every example in PowerShell … Read more