Skip to main content

Powershell: Get-Uptime


Start with Powershell 6, there is Get-Uptime cmdlet to tell how long the system running.

Example with Powershell Core on RHEL 7.6

[tuyendq@rhel1 ~]$ pwsh
PowerShell 6.2.0
Copyright (c) Microsoft Corporation. All rights reserved.

https://aka.ms/pscore6-docs
Type 'help' to get help.
PS /home/tuyendq> Get-Uptime -Since

Monday, December 31, 2018 10:42:03 PM
PS /home/tuyendq> Get-Uptime

Days              : 150
Hours             : 22
Minutes           : 14
Seconds           : 34
Milliseconds      : 0
Ticks             : 130400740000000
TotalDays         : 150.926782407407
TotalHours        : 3622.24277777778
TotalMinutes      : 217334.566666667
TotalSeconds      : 13040074
TotalMilliseconds : 13040074000


PS /home/tuyendq>

You will get error with Powershell version earlier than 6.0. Let's try with PSVersion 5.1.x on Windows 10

PS F:\Projects\lthwpowershell> $PSVersionTable

Name                           Value
----                           -----
PSVersion                      5.1.17763.503
PSEdition                      Desktop
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0...}
BuildVersion                   10.0.17763.503
CLRVersion                     4.0.30319.42000
WSManStackVersion              3.0
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1


PS F:\Projects\lthwpowershell> Get-Uptime
Get-Uptime : The term 'Get-Uptime' is not recognized as the name of a cmdlet, function, script
file, or operable program. Check the spelling of the name, or if a path was included, verify
that the path is correct and try again.
At line:1 char:1
+ Get-Uptime
+ ~~~~~~~~~~
    + CategoryInfo          : ObjectNotFound: (Get-Uptime:String) [], CommandNotFoundException
    + FullyQualifiedErrorId : CommandNotFoundException

PS F:\Projects\lthwpowershell>

Popular posts from this blog

Linux command: Check Current Shell

What is your current shell ?

Java: Free Online Courses

The Java™ Tutorials by Oracle The Java Tutorials are practical guides for programmers who want to use the Java programming language to create applications. They include hundreds of complete, working examples, and dozens of lessons. Groups of related lessons are organized into "trails". https://docs.oracle.com/javase/tutorial/ Learn to Program in Java at edX.ogr Get started on the path to becoming a software engineer by learning core coding skills in Java—one of the most popular programming languages. https://www.edx.org/course/learn-to-program-in-java-0 Java Tutorial by javapoint.com https://www.javatpoint.com/java-tutorial Java Tutorial by SoloLearn.com I love SoloLearn because I can learn Java - and other popular programming languages - anywhere, any time on your mobile devices. https://www.sololearn.com/Course/Java/ Java on Azure https://docs.microsoft.com/en-us/learn/paths/java-on-azure/

Powershell: Get-ChildItem

List, search/find files and directories with Get-ChildItem cmdlet.