'Join date and time as datetime format and pass it in schedule trigger powershell
I have below date and time in 2 separate variable. I am trying to combine these 2 as date time and create a scheduler based on that but getting error
Exception calling "ParseExact" with "3" argument(s): "String was not recognized as a valid DateTime."
At line:2 char:1
+ $dt1 = [datetime]::ParseExact($dt, 'g',[CultureInfo]::InvariantCultur ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [], MethodInvocationException
+ FullyQualifiedErrorId : FormatException
Below is my code
$L_Friday="25/02/2022"
$dt = $L_Friday + " " + "10:00:00 AM"
$dt1 = [datetime]::ParseExact($dt, 'dd/MM/yyyy hh:mm:ss',[CultureInfo]::InvariantCulture)
$Trigger = New-ScheduledTaskTrigger -Once -At ""
Please need your help to get the issue here
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
