I'm trying to get this to work within a PowerShell script, but it comes back with not defined.
$file = Get-Content "C:\log\clock.log"
$checktime = $(Get-Date).AddHours(-1)
$containsWord = $file | %{$_ -match "Calling ClockServer.stop()"} | $checktime
if ($containsWord -contains $true) {
Write-Host "Calling ClockServer.stop() text has been found"
} else {
Write-Host "Calling ClockServer.stop() text hasn't been found"
}
Would really appreciate the help.
Cheers
The script works if I remove the | $checktime part at the end of $containsWord variable.