I am having an issues and I can not see why it is doing this. I have a script to access event logs and it will pull the data but at the end of the first unit I get en error message but it continues to the next unit. Here is the code that I am using:
$aec=(Get-WinEvent -LogName application -ComputerName $dn | where {($_.timecreated -ge (Get-Date).adddays(-2)) -and (($_.level -like "2") -or ($_.level -like "1"))})
$sec=(Get-WinEvent -LogName system -ComputerName $dn | where {($_.timecreated -ge (Get-Date).adddays(-2)) -and (($_.level -like "2") -or ($_.level -like "1"))})
The error I get on the system log is:
Get-WinEvent : The description string for parameter reference (%1) could not be found
At C:\Users\chekal\Documents\audit check.ps1:25 char:21
+ $sec=(Get-WinEvent <<<< -LogName system -ComputerName $dn | where {($_.timecreated -ge (Get-Date).adddays(-2)) -and (($_.level -
like "2") -or ($_.level -like "1"))})
+ CategoryInfo : NotSpecified: (:) [Get-WinEvent], EventLogException
+ FullyQualifiedErrorId : The description string for parameter reference (%1) could not be found,Microsoft.PowerShell.Commands.GetWinE
ventCommand
It still produces output and it is read able I am wondering if there is something wrong with my logic. The second time through for the call it has not errors.