I'm pretty new to PowerShell and I'm trying to get a script running which checks for an error code in the last 5 lines of a log file. If the script finds an error, it should restart a service otherwise it should loop back to the top and do it again.
if(Get-Content C:\x\x\x\Log.log -last 5 | Select-String -pattern "Error" -Quiet){
Restart-Service -Name xxx -Force
}
else