title: Exclude records in CSV file based on exclusion criteria in Config file using PowerShell
body: <p>The use case I am working on is to extract details from a command prompt the list of services running for a specific application such as Tableau, etc. The Output is usually in the below format</p>
  <p><strong>File content in Tableau Services</strong></p>
  <pre><code>'Service 0' is running
  'Service 1' is running
  'Service 2' is running
  'Service 3' is running
  'Service 4' is running
  'Test Service 5' is stopped
  'SAML Service 6' is stopped
  'Database Service 7' is stopped
  'Tableau Service 8' is stopped
  'Service 9' is running
  'Service 10' is running
  'Service 11' is running
  'Service 12' is stopped
  'Service 13' is running
  'Service 14' is running
  'Service 15' is stopped
  </code></pre>
  <p><strong>The final outcome should give the list of services that have stopped</strong></p>
  <pre><code>Service 12
  Service 15
  </code></pre>
  <p><strong>Script</strong></p>
  <pre><code> #EXTRACT THE CONTENTS FROM THE TABLEAU SERVICES
      $content = Get-Content 'C:\Tableau Services\TableauServices.txt'
      $content.replace(&quot;`t&quot;, &quot;&quot;).Replace(&quot; is &quot;,&quot;,&quot;).replace(&quot;.&quot;,&quot;&quot;).Replace(&quot;'&quot;,&quot;&quot;).Trim() | select -Skip 2 | Out-File 'C:\Tableau Services\TableauServices.csv'
      
      $iRunningNumber=1
      #Extract Services which have Stopped
      Write-Host (&quot;The List of Services that have stopped are as below: - &quot;)
      Import-CSV -Path 'C:\Tableau Services\TableauServices.csv' `
                  -delimiter ”,” `
                  -Header ServiceName, Status | 
                      Where-Object {$_.ServiceName -notlike &quot;*Test Service 5*&quot; -AND $_.ServiceName - notlike &quot;*SAML Service 6*&quot; -AND $_.ServiceName -notlike &quot;*Database Service 7*&quot; -AND $_.ServiceName -notlike &quot;*Tableau Service 8*&quot;} | 
                       Select-Object ServiceName, Status |
                          Where-Object {$_.Status -match &quot;Stopped*&quot;} | 
                              ForEach-Object {&quot;$($iRunningNumber).) $($_.ServiceName)&quot;; $iRunningNumber++}
                      
  </code></pre>
  <p>Currently, the Services to be excluded are hard-coded in the code. I would like to have these conditions extracted from a configuration file and then searched and excluded from the final list.</p>
  <p><strong>I have another file which will contain the list of services to be ignored as below: -
  SearchFile.txt</strong></p>
  <pre><code>Test Service 5
  SAML Service 6
  Database Service 7
  Tableau Service 8
  </code></pre>
  <p>I have tried everything that I know of and still no solution. Request your help</p>