In my script test.ps1
I try to calculate the difference in time by using the New-TimeSpan
function:
$foo = "00:06:45.0"
$bar = "00:10:44.0"
$StartDate=[datetime]"01/01/2018 $foo"
$EndDate=[datetime]"01/01/2018 $bar"
Write-Output ($StartDate)
Write-Output ($EndDate)
NEW-TIMESPAN –Start $StartDate –End $EndDate
When I run the script, I get the (German) error:
New-TimeSpan : Es wurde kein Positionsparameter gefunden, der das Argument "â€Start 01/01/2018 00:06:45 â€End"
akzeptiert.
In C:\Users\me\Downloads\test.ps1:8 Zeichen:1
+ NEW-TIMESPAN –Start $StartDate –End $EndDate
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidArgument: (:) [New-TimeSpan], ParameterBindingException
+ FullyQualifiedErrorId : PositionalParameterNotFound,Microsoft.PowerShell.Commands.NewTimeSpanCommand
What makes me wonder are the strange characters in the string â€
?!
When I enter all the commands step by step in the PowerShell directly, it works without any problems.
Do you know what could be the issue here? Thanks!