Output format for service starttime query

Tagged: 

This topic contains 2 replies, has 2 voices, and was last updated by Profile photo of J Schupbach J Schupbach 3 weeks ago.

  • Author
    Posts
  • #72016
    Profile photo of J Schupbach
    J Schupbach
    Participant

    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
    Shoop

  • #72019
    Profile photo of Don Jones
    Don Jones
    Keymaster

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

    • #72025
      Profile photo of J Schupbach
      J Schupbach
      Participant

      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.

You must be logged in to reply to this topic.