Output format for service starttime query

Welcome Forums General PowerShell Q&A Output format for service starttime query

This topic contains 2 replies, has 2 voices, and was last updated by

1 year, 11 months ago.

  • Author
  • #72016

    Topics: 1
    Replies: 1
    Points: 0
    Rank: Member

    Hey guys –
    Forgive the PS noob question. I am struggling thru self learning PowerShell scripting. I finally got this remote command syntax corrected. The objective is to see a service up time on a remote server. I changed the server name and service name for this example. Here is the command –

    Invoke-Command -ComputerName server {New-TimeSpan -Start (Get-Process winlogon).StartTime}

    to which I get this sample output –
    Days : 0
    Hours : 12
    Minutes : 49
    Seconds : 20
    Milliseconds : 850
    Ticks : 461608503901
    TotalDays : 0.534269101737268
    TotalHours : 12.8224584416944
    TotalMinutes : 769.347506501667
    TotalSeconds : 46160.8503901
    TotalMilliseconds : 46160850.3901
    PSComputerName : servername

    All of this information is fine, but too much for my purposes. All I want is the days, hours minutes, and PSComputername. I am not interested in writing this output to a file. I just want the details at a higher level. What do I need to add to the command to get the desired output?

    I appreciate your attention

  • #72019

    Topics: 13
    Replies: 4872
    Points: 1,811
    Helping HandTeam Member
    Rank: Community Hero

    Can you use Select to just choose the bits you want?

    • #72025

      Topics: 1
      Replies: 1
      Points: 0
      Rank: Member

      I would imagine. I hadn't thought of that. I'm just not sure of the syntax or position it's placed in. I struggled for a few days with this command line before I realized I needed the {} on either side of the last section.

The topic ‘Output format for service starttime query’ is closed to new replies.

denizli escort samsun escort muğla escort ataşehir escort kuşadası escort