Get-ZabbixLog.ps1

function Get-ZabbixLog
{
  <#
      .SYNOPSIS
      Gets entries in Zabbix Log.
      .DESCRIPTION
      Grabs latest entries from a Zabbix Log. Dynamically gathers .log definition from .conf file.
      .EXAMPLE
      Get-ZabbixLog -Computer Agent1 -Entries 15
      Gets latest 15 entries.
  #>

  [CmdletBinding()]
  param
  (
    [Parameter(Mandatory=$true, Position=0)]
    [Alias('Server')]
    [System.String]
    $Computer,

    [Parameter(Mandatory=$false, Position=1)]
    [System.Int32]
    $Entries = 25
  )
  
  $confPath = (Get-ZabbixAgent -Computer $Computer).confPath 
  $remoteConfPath = (($confPath.Replace(':','$')).insert(1,"\\$Computer\")).Replace('"','')
  $LogDefinition = ((cat $remoteConfPath | ? {$_ -match '^LogFile='}) -split '=' | Select-Object -Last 1 ) 
 
  if ($LogDefinition -match ':') {
    $remoteLogPath = ((($LogDefinition.Replace(':','$')).insert(1,"\\$Computer\")).Replace('"',''))
    $remoteLogPath = $remoteLogPath[1..($($remoteLogPath.Length))] -join ''
    $remoteLogPath =  $remoteLogPath.Replace("\$\","\$($LogDefinition[0])`$\")
    $remoteLogPath
  }
  ELSE {
    $remoteLogPath = "$((get-item $remoteConfPath).Directory.FullName)\$LogDefinition"
  }
  Write-Output "Log File Retrieved: $remoteLogPath"
  Get-FileTail -Count $Entries $remoteLogPath
}