查找 Windows 上次啟動時間的 3 種簡單方法

已發表: 2022-03-04

如果您想了解檢查 Windows 機器上次啟動時間的不同方法,那麼您來對地方了。

網絡管理員使用 Windows 上次啟動時間作為衡量系統中可能出現的日常問題的指標。

讓我們首先查看幾種不同的方法來識別 Windows 上次啟動時間。

電源外殼

有一些方法可以利用 Power Shell 檢查您的 Windows 機器的正常運行時間或上次啟動時間。

獲取 CimInstance cmdlet

PowerShell 中的 Get-CimInstance cmdlet 可用於獲取系統最近的啟動時間。

Get-CimInstance cmdlet(WMI 類的實例)從 win32 操作系統類名中獲取系統信息,並通過管道運算符將其提供給第二條指令。 它從 CIM 服務器獲取類的 CIM(通用信息模型)實例。

第二個命令從 CIM 中選擇CSNamelastBootupTime屬性,並作為結果顯示 windows 機器的上次啟動時間。

首先,打開 PowerShell 並以管理員身份運行它。

只需在 PowerShell 中鍵入以下命令即可查看上次啟動時間。

 Get-CimInstance -ClassName win32_operatingsystem | select csname, lastbootuptime

樣本輸出:

 PS C:\Users\geekflare> Get-CimInstance -ClassName win32_operatingsystem | select csname, lastbootuptime csname lastbootuptime ------ -------------- LAPTOP-9A5G7BR4 2/20/2022 1:26:40 PM

下面的gcim命令以天、小時和分鐘的列表方式顯示 Windows 系統的正常運行時間。 它不是上次啟動時間,而是顯示自上次啟動以來系統的正常運行時間。

 (get-date) - (gcim Win32_OperatingSystem).LastBootUpTime

這裡, gcim代表 Get – CimInstance。

樣本輸出:

 PS C:\Users\geekflare> (get-date) - (gcim Win32_OperatingSystem).LastBootUpTime Days : 7 Hours : 8 Minutes : 44 Seconds : 38 Milliseconds : 884 Ticks : 6362788845605 TotalDays : 7.36433894167245 TotalHours : 176.744134600139 TotalMinutes : 10604.6480760083 TotalSeconds : 636278.8845605 TotalMilliseconds : 636278884.5605

如果您使用的是 PowerShell 6 或更高版本,您可以使用以下命令輕鬆獲取 Windows 正常運行時間和上次啟動時間:

 Get-Uptime -Since

要查看 Get-CimInstance 的所有屬性和方法,請使用以下命令。

 Get-CimInstance Win32_OperatingSystem | Get-Member

此命令提供所有 Get-CimInstance 方法及其屬性的信息。

獲取 WmiObject

您可以使用 PowerShell Get-WmiObject 命令輕鬆查詢 PC 的上次啟動時間,如下所示。

 (Get-WmiObject Win32_OperatingSystem).LastBootUpTime

樣本輸出:

 PS C:\Users\geekflare> (Get-WmiObject Win32_OperatingSystem).LastBootUpTime 20220220132640.500000+330

你會看到一個起初看起來很尷尬的輸出,但它並不難閱讀和理解。 您可以輕鬆計算出您的 Windows 機器的上次啟動時間。

以下信息可用於分解LastBootUpTime 20220220132640.500000+330

  • 年份: 2022。
  • 月: 02。
  • 天數: 20。
  • 小時: 13。
  • 分鐘: 26。
  • 秒: 40。
  • 毫秒: 500000。
  • 格林威治標準時間: +330(比格林威治標準時間提前 5 個半小時)。

或者您也可以使用另一個Get-WmiObject 命令來查詢系統的上次啟動時間。

 Get-WmiObject win32_operatingsystem | select csname, @{LABEL='LastBootUpTime';EXPRESSION={$_.ConverttoDateTime($_.lastbootuptime)}}

lastbootuptime會被轉換成大整數格式,最終以可讀的格式顯示出來。

樣本輸出:

 PS C:\Users\geekflare> Get-WmiObject win32_operatingsystem | select csname, @{LABEL='LastBootUpTime';EXPRESSION={$_.ConverttoDateTime($_.lastbootuptime)}} csname LastBootUpTime ------ -------------- LAPTOP-9A5G7BR4 2/20/2022 1:26:40 PM

網絡統計工作站

net statistics 命令顯示系統統計信息,例如自計算機上次啟動以來接收到的數據字節數和總正常運行時間。

 net statistics workstation | select-string "Statistics"

您還可以使用以下快捷方式:

 net stats work | select-string "Stat"

樣本輸出:

 PS C:\Users\geekflare> net statistics workstation | select-string "Statistics" Workstation Statistics for \\LAPTOP-9A5G7BR4 Statistics since 2/20/2022 1:28:32 PM

系統信息

systeminfo實用程序命令可用於通過加載和分析處理器、修補程序和 Hyper-V 信息來獲取計算機的最近啟動時間。

 systeminfo

此命令顯示主機名、操作系統版本、構建類型、配置、BIOS 版本、啟動時間、軟件安裝日期和所有詳細信息。

從所有這些數據中,如果您只想查看特定的所需數據,則需要將 Select -string 附加實用程序傳遞給systeminfo命令。

只需在 PowerShell 終端中鍵入以下命令即可查看上次啟動時間。

 systeminfo | Select-String "OS version","System Boot Time"

此處, Select-String cmdlet 使用正則表達式匹配在輸入字符串和文件中搜索文本模式。

上述命令獲取本地計算機最近的重新啟動時間,並將系統的操作系統版本和 windows 系統上次啟動時間打印到終端,如下所示。

樣本輸出:

 PS C:\Users\geekflare> systeminfo | Select-String "OS version","System Boot Time" OS Version: 10.0.22000 N/A Build 22000 System Boot Time: 2/20/2022, 1:26:40 PM BIOS Version: Insyde F.18, 3/15/2019

命令提示符

您還可以使用命令行檢查 Windows 系統的正常運行時間或上次啟動時間,其中包含一些命令和實用程序,例如net statswmicsysteminfo

系統信息

命令systeminfo顯示有關 Windows 操作系統及其配置的一般信息。 它顯示上次啟動 Windows 的時間。 如果您想要正常運行時間,您需要手動確定自上次啟動以來經過了多少時間。

打開命令提示符並鍵入以下命令。

 systeminfo | find "System Boot Time"

樣本輸出:

 C:\Users\geekflare>systeminfo | find "System Boot Time" System Boot Time: 2/20/2022, 1:26:40 PM

WMIC

WMIC(Windows Management Instrumentation 命令行)命令將為您提供計算機上次啟動時間的字符串表示形式。 結果被格式化為四位數的年份,月、日、小時、分鐘和秒為兩位數。

打開命令提示符並鍵入以下命令。

 wmic path Win32_OperatingSystem get LastBootUpTime

樣本輸出:

 C:\Users\geekflare>wmic path Win32_OperatingSystem get LastBootUpTime LastBootUpTime 20220220132640.500000+330

此輸出可以讀取為 2022、第 2 個月、第 20 天、第 13 小時(或下午 1:00)、第 26 分鐘等。

淨統計

net statistics 命令顯示系統統計信息,例如接收的數據字節數、傳輸的數據字節數、建立的連接數以及自上次啟動計算機以來的總正常運行時間。

要查看 Windows 機器中運行的服務,請使用以下命令。

 net stats

該命令僅顯示系統中可用的正在運行的服務。

我們可以通過以下命令使用上下文 NET STATISTICS 獲取服務器或工作站的統計信息。

 net stats workstation

在這裡,我在命令中提供了工作站以查看統計信息。

樣本輸出:

 C:\Users\geekflare>net stats workstation Workstation Statistics for \\LAPTOP-9A5G7BR4 Statistics since 2/20/2022 1:28:32 PM Bytes received 66780 Server Message Blocks (SMBs) received 18 Bytes transmitted 63746 Server Message Blocks (SMBs) transmitted 0 Read operations 0 Write operations 0 Raw reads denied 0 Raw writes denied 0 Network errors 0 Connections made 0 Reconnections made 0 Server disconnects 0 Sessions started 0 Hung sessions 0 Failed sessions 0 Failed operations 0 Use count 10 Failed use count 0 The command completed successfully.

該命令可以在批處理文件中使用,並且可以使用“find”命令過濾輸出。 例如,如果您只想查找系統的上次啟動時間,請使用以下命令。

 net statistics workstat

樣本輸出:

 C:\Users\geekflare>net statistics workstation | find "Statistics" Workstation Statistics for \\LAPTOP-9A5G7BR4 Statistics since 2/20/2022 1:28:32 PM

如果您想查找 Windows Server 的正常運行時間,該命令將變為net statistics server

任務管理器

這是檢查設備正常運行時間的最簡單方法。 它不顯示上次啟動時間,而是顯示自上次啟動以來系統的正常運行時間。

  • 要打開任務管理器,只需使用 Ctrl + Shift + Esc 鍵盤快捷鍵。
  • 導航到性能選項卡。
  • 系統正常運行時間將顯示在窗口底部附近。

這意味著系統在 8 天 8 小時 29 分鐘之前重新啟動。

結論

這些是快速獲取windows系統最近的啟動時間或正常運行時間的一些方法。

每個命令都有自己的一組好處。 您可以選擇最符合您需求的方式。

我希望您發現這篇文章對於學習如何以不同方式獲取 Windows 系統的上次啟動時間非常有用。

您可能也有興趣了解監控 Windows 服務器的頂級工具。