私はユーザーの入力に基づいて結果を取得するためのスクリプトを書いています、ここでユーザーは日付または日付の時間を与えることができます...私は入力に基づいて結果を取得する必要があります日付時刻)。powershellの日付の異なる方法を入力
$StartDate = Read-Host -Prompt 'Enter the start date of the logs, Ex: 17/07/2017 or 17/07/2017 09:00:00'
$culture = [Globalization.CultureInfo]::InvariantCulture
$pattern = 'dd\/MM\/yyyy HH:mm:ss', 'dd\/MM\/yyyy'
$params['After'] = [DateTime]::ParseExact($StartDate, $pattern, $culture)
以下のエラー取得:私は以下のように試してみました
Exception calling "ParseExact" with "3" argument(s): "String was not recognized as a valid DateTime."
+ $params['After'] = [DateTime]::ParseExact <<<< ($StartDate, $pattern, $culture)
+ CategoryInfo : NotSpecified: (:) [], MethodInvocationException
+ FullyQualifiedErrorId : DotNetMethodException
を提案してくださいは、私はここで何をしないのです。