title: Get Column values from text file
body: <p>Below is the text file data I have</p>
  <pre><code>  Disk ###  Status         Size     Free     Dyn  Gpt
    --------  -------------  -------  -------  ---  ---
    Disk 0    Online          100 GB  1024 KB         
    Disk 1    Online         6144 MB  1024 KB         
    Disk 2    Online          200 GB  1024 KB         
    Disk 3    Online           10 GB  1024 KB         
  
  
  </code></pre>
  <p>I want to put this data in csv like below, removing the last 2 columns and adding the server value</p>
  <pre><code>
  server  Disk ###  Status         Size     Free     
  ------  --------  -------------  -------  ------- 
  s1      Disk 0    Online          100 GB  1024 KB         
  s1      Disk 1    Online         6144 MB  1024 KB         
  s1      Disk 2    Online          200 GB  1024 KB         
  s1      Disk 3    Online           10 GB  1024 KB         
  
  
  </code></pre>
  <p>below is the code</p>
  <pre><code>$list = Get-Content -Path &quot;C:\server.txt&quot;
  foreach($server in $list)
  {
  
      $diskpart = cmd /c 'echo list disk | diskpart'
      
  }
  
  $Lines = $diskpart
  $Out = $False
  $Line=@()
  ForEach ($Line In $Lines)
  {
      If ($Line -match 'DISKPART&gt;') 
      {
          $Out = $False
      }
      If ($Out -eq $True) 
      {
          $Line | Out-File &quot;C:\d.txt&quot; -Append
      }
      If ($Line -match 'DISKPART&gt;') 
      {
          $Out = $True
      }
  }
  
  $data  = Import-Csv -Path C:\d.txt
  </code></pre>
  <p>I tried reading line using foreach,but getting output with headers and ---</p>
  <pre><code>Disk ###  Status         Size     Free     Dyn  Gpt
  ---------------------------------------------------
  Disk 0    Online          100 GB  1024 KB          
  
  </code></pre>
  <p>Please let me know how can I extract columns from text file and append the servername to it. Need some idea to do this</p>