title: Creating an array from values in a text file with powershell
body: <p>I have a text file with this content:</p>
  
  <pre><code>SEGMENTS="worker01 worker02 worker03 worker04"
  WORKER_SEGMENTS="worker01 worker02 worker03 worker04"
  #SEGMENTS="worker01"
  #WORKER_SEGMENTS="worker01"
  </code></pre>
  
  <p>I read this file from another powershell script and I want to to create an array of the <code>WORKER_SEGMENTS</code> values. I have gotten so far:</p>
  
  <pre><code>$workers = Get-Content $strPath"\worker\conf\segments.conf" | Where-Object {$_ -like "*WORKER_SEGMENTS*"}
  Write-Host $workers
  </code></pre>
  
  <p>This yields:</p>
  
  <pre><code>PS Q:\mles\etl-i_test\rc&gt; .\etl.ps1
  WORKER_SEGMENTS="worker01 worker02 worker03 worker04" #WORKER_SEGMENTS="worker01"
  </code></pre>
  
  <p>I only need the <code>worker01</code>, <code>worker02</code>, <code>worker03</code>, <code>worker04</code> from <code>WORKER_SEGMENTS</code> (without the leading #) as an array. How do I achieve this?</p>