我编写了一个小脚本来从应用程序中检索过去 10 天的事件日志,但我收到了错误消息。任何想法为什么会出现错误?
Where-Object:无法绑定参数“FilterScript”。无法将值“False”转换为类型“System.Management.Automation.ScriptBlock”。错误:“从 'System.Boolean' 到 'System.Management.Automation.ScriptBlock' 的无效转换。”
#Sets the application log to query
$Log ="Application"
$FilterHashTable = @{LogName=$Log}
#stores the computer name
$ComputerName = $env:COMPUTERNAME
#sets the date 10 days ago
$DeleteDate = Get-Date
$DeleteDate = $DeleteDate.AddDays(-10)
Write-Verbose $DeleteDate
#retrieve WMIevent and logs the information
$Winevent = Get-WinEvent -ComputerName $ComputerName -FilterHashTable $FilterHashTable -ErrorAction SilentlyContinue
# Filter on time
$Winevent | where-object ($_.timecreated -gt $DeleteDate)