嗨我得到这个格式错误,当我尝试并指定一个DateTime参数的值。这里是我的脚本这我在PowerShell ISE中按F5运行:
param
(
[Parameter(Mandatory=$true)]
[datetime]$startTime
)
write-output $startTime
当我运行它,它说,这Supply values for the following parameters:
。我曾尝试指定以下:
startTime: get-date
startTime: (get-date)
startTime: new-object DateTime(2015,03,31)
startTime: (new-object DateTime(2015,03,31))
startTime: $(get-date)
startTime: $((get-date))
startTime: $(new-object DateTime(2015,03,31))
startTime: $((new-object DateTime(2015,03,31)))
不过,我不断收到此错误:
Cannot recognise $startTime as a system.datetime due to a format error
UPDATE: 原来你需要指定类似3/31/2015
。 这是为什么?上述DateTime
对象的格式有什么问题?
你有没有尝试过像'3/31/2015'这样简单的参数输入? – TheMadTechnician 2015-03-31 03:23:43
这有效! 但是为什么?我以错误的格式提供的论点如何? – 2015-03-31 03:26:24