Formatting Assistance

This topic contains 2 replies, has 2 voices, and was last updated by  Andy 1 year, 5 months ago.

  • Author
  • #63652


    Hi Community,

    I am trying to get the below to output into a more readable format – perhaps to Out-gridview

    $services = Get-Service

    $services | Where-Object {$_.requiredservices} | Select-Object -Property name, @{n='requiredservices'; e={$}}, @{n='Status';e={$_.requiredservices.status}}

    I would like to try and get requiredservices and status to 'ungroup' and be on a separate line each so AppIDSvc would have 3 x lines with each required service and status? Any ideas appreciated

    Name requiredservices Status
    —- —————- ——
    AppIDSvc {RpcSs, CryptSvc, AppID} {Running, Running, Stopped}
    Appinfo {RpcSs, ProfSvc} {Running, Running}
    AudioEndpointBuilder PlugPlay Running
    AudioSrv {MMCSS, RpcSs, AudioEndpointBuilder} {Stopped, Running, Running}
    AxInstSV rpcss Running
    BFE RpcSs Running
    BITS {RpcSs, EventSystem} {Running, Running}
    Browser {LanmanServer, LanmanWorkstation} {Running, Running}

  • #63658

    Daniel Krebs

    Below works for me. Let me know what you think.

    Get-Service | ForEach-Object {
        if ($_.RequiredServices) {
            foreach ($service in $_.RequiredServices) {
                [PSCustomObject] @{
                    'Name' = $_.Name
                    'RequiredService' = $service.Name
                    'Status' = $service.Status
    • #63708


      Hey Daniel,

      works for me as well – thanks so much

You must be logged in to reply to this topic.