title: Output of select-string has @{ in output
body: <p>I am trying to get the services that are in auto mode but is not running and start them, except for few service which i want to ignore from script to check, is there way out to get the desired output with proper formatting as seen in image 2, because of the select-string output my script if not able to take service.name as variable.
  i am using below command </p>
  
  <pre><code>Get-CimInstance win32_service -Filter "startmode = 'auto' AND state != 'running' "  | select name, startname, exitcode | Select-String   "gupdate|RemoteRegistry"  -NotMatch
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/VmWR8.jpg" rel="nofollow noreferrer">output that i am getting is</a></p>
  
  <p><a href="https://i.stack.imgur.com/wILJZ.png" rel="nofollow noreferrer">but the desired output is </a></p>
  
  <p>below is my script </p>
  
  <pre><code>    $Services = Get-CimInstance win32_service -Filter "startmode = 'auto' AND state != 'running' "  | select name, startname, exitcode | Select-String  -Pattern "gupdate|RemoteRegistry" -NotMatch
  $ServicesRunning = Get-CimInstance win32_service -Filter "state = 'running'"
  if ([string]::IsNullOrEmpty($Services)){
      Write-Output "OK: All services running | ServicesRunning=$($ServicesRunning.Count);0;0;0;0"
      $host.SetShouldExit(0)
  }
  else{
      $ServicesStopped=""
      ForEach ($Service in $Services){
          Start-Service @($Service.Name) -ErrorAction SilentlyContinue | Out-Null  
          if ($(Get-Service -Name ($Service.Name)).Status -eq "running"){
              $ServicesStopped += "($Service.Name)(Started manually),"
              If ($ExitCode -eq 0){
                  $ExitCode = 1
              }
          }
          Else{
              $ServicesStopped += "$($Service.Name)(Stopped),"
              $ExitCode = 2
          }
      }
      If ($ExitCode -eq 2){
          Write-Output "CRITICAL: Service(s) stopped: $($ServicesStopped.TrimEnd(",")) | ServicesRunning=$($ServicesRunning.Count);0;0;0;0"
          $host.SetShouldExit(2)
      }
      Else{
          Write-Output "WARNING: Service(s) stopped: $($ServicesStopped.TrimEnd(",")) | ServicesRunning=$($ServicesRunning.Count);0;0;0;0"
          $host.SetShouldExit(1)
      }
  }
  </code></pre>