title: How to edit my script to combine its outputs in one table per server from serverlist?
body: <p>Could you please inform me how can I make my script to format its output in a single table for all "services" per "server"?</p>
  
  <p>Please find my current PowerShell script below:</p>
  
  <pre><code>$serverList = gc computer.txt
  $serviceList = gc service.txt
  
  if ((Test-Path OUTPUT.txt) -eq $true) {
  Write-Host "Deleting existing OUTPUT file"
  Remove-Item OUTPUT.txt
  }
  
  ForEach ($server in $serverList)
  {
      $style = @{Expression={$server};Label="Server Name";width=30}, `
      @{Expression={$_.Name};Label="Service Name";width=20}, `
      @{Expression={$_.StartMode};Label="StartMode";width=10}, `
      @{Expression={$_.State};Label="State";width=10}, `
      @{Expression={$_.ProcessId};Label="ProcessId";width=10}
  
  Write-Host "Starting Service Check on $server"
      ForEach ($service in $serviceList)
      {
          Get-WmiObject -Class Win32_Service -ComputerName $server -Filter "Name='$service'" | Select-Object -Property Name, StartMode, State, ProcessId | Format-Table $style | Out-File OUTPUT.txt -Append
      }
  Write-Host "Service Check Completed on $server"
  }
  </code></pre>