運行以下ps1,但datetime參數在出錯時重新執行。PowerShell 5在
調試顯示的日期是正確的($早日重啓= I輸入的日期)
的主機IP參數被傳遞,因此似乎有必要傳遞,我不知道的日期時間一個特殊的技巧。
我收到的錯誤是:
無法在參數驗證參數「後」。參數爲空或 爲空。提供非空或空的參數,然後再次嘗試 命令。
任何幫助,非常感謝。
param(
[Parameter(Mandatory=$True)]
[string]$HostIP,
[Parameter(Mandatory=$True)]
[datetime]$earlydate,
[Parameter(Mandatory=$True)]
[datetime]$latedate
)
Invoke-Command {Get-EventLog Security -After $earlydate -Before $latedate} -ComputerName $HostIP |
Export-Csv c:\Events\$HostIP.csv
完美!這工作,非常感謝你的反應如此之快! –