title: how to assign the output of a string separated by column to a variable in PowerShell
body: <p>I am trying to write a PowerShell script to get the required contents from a log/text file. The file looks like below:</p>
  <pre><code>node1 : data1
  node2 : data2
  Administrators : Data is Not Available at this moment
  desiredouput : data3
  format : format-type
  node1 : data4
  node2 : data5
  Administrators : user1, user2, user3, user4, user5, user6
  desiredoutput : data6
  format : format-type
  node1 : data7
  node2 : data8
  Administrators : user1, user2, user3, user4, user5, user6, user7, user8, user9, user10, user11, 
  user12, user13, user14, user15, user16, user17, user18, user19, user20
  desiredoutput : data9
  format : format-type
  .....
  the sequence continues
  .....
  </code></pre>
  <p>As you can see after every five lines, the new data will be displayed to the same variable on the left.</p>
  <p>I want to fetch the data after <strong>:</strong> in each and every line and assign that to a variable. Here is the code I am writing:</p>
  <pre><code>        $deliverycontent = @()
          $filecontent = Get-Content -Path &lt;path to the text file&gt;
          $datacount = $filecontent.Length
          for ($i=0; $i -lt $datacount; $i+=5)
          {
              $temp = &quot;&quot; |select Header1, Header2, Header3, Header4, Header5
              $temp.Header1 = ($filecontent[$i]).Split(&quot;:&quot;)[1]
              $temp.Header2 = ($filecontent[$i+1]).Split(&quot;:&quot;)[1]
              $temp.Header3 = ($filecontent[$i+2]).Split(&quot;:&quot;)[1]
              $temp.Header4 = ($filecontent[$i+3]).Split(&quot;:&quot;)[1]
              $temp.Header5 = ($filecontent[$i+4]).Split(&quot;:&quot;)[1]
              $deliverycontent += $temp
          }
  
  </code></pre>
  <p>while running the above script, I am seeing the data is not properly assigned especially for the output of the <strong>administrators</strong> because the output of the administrators is a huge string and it is printing the output in the next line instead in a single line in the text file so the powershell output is not displaying as expected. How can I assign the entire string of the administrators to a single variable even it is printed in the next lines as per the loop condition provided.</p>
  <p>The desired output is:</p>
  <pre><code>Header1: data1
  Header2: data2
  Header3 : Data is Not Available at this moment
  Header4: data3
  Header5: format-type
  
  Header1: data4
  Header2: data5
  Header3 : user1, user2, user3, user4, user5, user6
  Header4: data6
  Header5: format-type
  
  Header1: data7
  Header2: data8
  Header3 : user1, user2, user3, user4, user5, user6, user7, user8, user9, user10, user11, user12,
  user13, user14, user15, user16, user17, user18, user19, user20                         
  Header4: data6
  Header5: format-type
  ....
  
  &lt;the sequence follows&gt;
  ....
  
  How can I achieve this?
  </code></pre>