title: etc/host file entries match or not if not match entries then send a Triger
body: <p>Here, I am new to PowerShell scripting. I am trying to do Host file entries should match every entry in a dynamic list of IP and DNS name entries from C:\Windows\System32\drivers\etc. Any mismatch will fail the audit.</p>
  <p>entries are</p>
  <pre><code>10.23.24.45           foo.com
  10.24.45.34           domain.com
  </code></pre>
  <p>Here is my code.</p>
  <pre><code>&quot;$Pattern = '^(?&lt;IP&gt;\d{1,3}(\.\d{1,3}){3})\s+(?&lt;Host&gt;.+)$'
  $File    = &quot;$env:SystemDrive\Windows\System32\Drivers\etc\hosts&quot;
  $Entries = @()
  
  (Get-Content -Path $File)  | ForEach-Object {
    If ($_ -match $Pattern) {
      $Entries += &quot;$($Matches.IP)  $($Matches.Host)&quot;
      Write-Host &quot; the values are $Entries&quot;
      $FailureMessage = &quot;IP and host entries are existing&quot;
    }
    else {
      $FailureMessage = &quot;IP and host entries are doesn't existing&quot;
    }
  }&quot;
  </code></pre>
  <p>But this is not working for me. Can you help here</p>