title: Capture Get-ChildItem results into string array for HTML output
body: <p>I'm writing a PowerShell script and I want to capture the list of files in a directory and store into a variable. Once captured I'd like to print it to an HTML file.  I've captured the data like this:</p>
  
  <pre><code>$listDownloads = Get-ChildItem -Force "C:\Users\Someuser\Downloads"
  </code></pre>
  
  <p>Now, I want to convert <code>$listDownloads</code> into a string and split it. How do I go about doing that?</p>
  
  <p>I've tried this: </p>
  
  <pre><code>$listSplit = $listDownloads.ToString().Split(" ")
  </code></pre>
  
  <p>but I get this output: </p>
  
  <pre><code>System.Object[]
  </code></pre>
  
  <p><strong>Updated:</strong></p>
  
  <pre><code>$html = '&lt;html&gt;'
  $body = '&lt;body&gt;'
  $p = '&lt;p&gt;'
  $pClose = '&lt;/p&gt;'
  $StatusDownloads = 'Directory of the Downloads Folder'
  $pTags = $p.ToString() + $StatusDownloads + $pClose.ToString();
  $listDownloads = (Get-ChildItem -Force "C:\Users\Someuser\Downloads").Name;
  
  
  
  
  function createHTML($addtoFile){
  
     $addtoFile | Add-Content 'status.html'
  
  }
  
  function printData($printData){
  
      Write-Output $printData
  }
  
  
  $html | Set-Content 'status.html'
  
  createHTML($html)
  createHTML($body)
  createHTML($pTags)
  createHTML($listDownloads)
  </code></pre>
  
  <p>When I try to print $listDownloads it gives me the data all on the same line (i.e. File 1 File 2) I want each file or folder displayed on a new line. How would I do that? If I were to type Get-ChildItem -Force "C:\Users\Someuser\Downloads" into Powershell it would give the list of files line by line. I want that type of output on my HTML page.</p>