none
Services Related Issue RRS feed

  • Question

  • Hey Scripting Guys,

    I am trying to check automatic services stopped on Multiple Machines using following command 

    Get-WmiObject -ComputerName 'localhost' -Class win32_service -ErrorAction SilentlyContinue | where {$_.Startmode -EQ "Auto" -and $_.State -NE "Running"}

    I have exported them to csv and the output look likes:-

    Server    Name                                             StartMode State  
    ------    ----                                             --------- -----  
    localhost gupdate                                          Auto      Stopped
    localhost RemoteRegistry                                   Auto      Stopped
    localhost VMware vCloud Automation Center Management Agent Auto      Stopped

    But i want the output look like

    Server    Name                                                                                                              startmode            Status
    ------    ----                                              
    localhost gupdate,RemoteRegistry,VMware vCloud Automation Center Management Agent       Auto              Stopped 

    Any leads will be helpful.

    Thanks!

    Thursday, July 26, 2018 3:50 PM

Answers

  • Then you have to flatten them out by doing some string manipulation.

    $results = Get-WmiObject -ComputerName 'localhost' -Class win32_service -Filter 'Startmode = "Auto" and State <> "Running"'
    $results.Name -join ','


    \_(ツ)_/

    • Marked as answer by Abhi79 Monday, July 30, 2018 10:06 AM
    Thursday, July 26, 2018 4:11 PM
  • $a=get-WmiObject -ComputerName $servers -Class win32_service -ErrorAction SilentlyContinue | where {$_.Startmode -EQ "Auto" -and $_.State -NE "Running" -and !($IgnoreServices -contains $_.Name)}
          $b=$a.name -join ","
    • Marked as answer by Abhi79 Monday, July 30, 2018 10:08 AM
    Monday, July 30, 2018 10:08 AM

All replies

  • Then you have to flatten them out by doing some string manipulation.

    $results = Get-WmiObject -ComputerName 'localhost' -Class win32_service -Filter 'Startmode = "Auto" and State <> "Running"'
    $results.Name -join ','


    \_(ツ)_/

    • Marked as answer by Abhi79 Monday, July 30, 2018 10:06 AM
    Thursday, July 26, 2018 4:11 PM
  • $a=get-WmiObject -ComputerName $servers -Class win32_service -ErrorAction SilentlyContinue | where {$_.Startmode -EQ "Auto" -and $_.State -NE "Running" -and !($IgnoreServices -contains $_.Name)}
          $b=$a.name -join ","
    • Marked as answer by Abhi79 Monday, July 30, 2018 10:08 AM
    Monday, July 30, 2018 10:08 AM