14 Replies Latest reply on Dec 6, 2019 12:31 PM by dkohler

    powershell get-content

    dkohler

      I'm trying to create a powershell monitor, to read a log file and look for a word.

       

      Script is as so:

       

      $Lines = Get-Content -path "C:\Windows\tracing\logfile.log"

      foreach ($Line in $Lines){

      if ($Line -like "*Successful*"){$Health = "good"}

      }

       

       

      I get this error when testing the script:

       

      Get-Content : Cannot find path 'C:\Windows\tracing\logfile.log' because it does not exist.

       

       

      But it does exist, and I am using sufficient credentials.