嗨我得到這個格式錯誤,當我嘗試並指定一個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