共用方式為


Get-ComputerRestorePoint

取得本機電腦上的還原點。

語法

Get-ComputerRestorePoint
   [[-RestorePoint] <Int32[]>]
   [<CommonParameters>]
Get-ComputerRestorePoint
   -LastStatus
   [<CommonParameters>]

Description

Get-ComputerRestorePoint Cmdlet 會取得本機計算機的系統還原點。 而且,它可以顯示最近嘗試還原計算機的狀態。

您可以使用 Get-ComputerRestorePoint 的資訊來選取還原點。 例如,使用序號來識別 Restore-Computer Cmdlet 的還原點。

只有 Windows 10 等用戶端作系統才支援系統還原點和 Get-ComputerRestorePoint Cmdlet。

範例

範例 1:取得所有系統還原點

在此範例中,Get-ComputerRestorePoint 取得所有本機計算機的系統還原點。

Get-ComputerRestorePoint

CreationTime           Description                    SequenceNumber    EventType         RestorePointType
------------           -----------                    --------------    ---------         ----------------
7/30/2019 09:17:24     Windows Update                 4                 BEGIN_SYSTEM_C... 17
8/5/2019  08:15:37     Installed PowerShell 7-prev... 5                 BEGIN_SYSTEM_C... APPLICATION_INSTALL
8/7/2019  12:56:45     Installed PowerShell 6-x64     6                 BEGIN_SYSTEM_C... APPLICATION_INSTALL

範例 2:取得特定序號

此範例會取得特定序號的系統還原點。

Get-ComputerRestorePoint -RestorePoint 4, 5

CreationTime           Description                    SequenceNumber    EventType         RestorePointType
------------           -----------                    --------------    ---------         ----------------
7/30/2019 09:17:24     Windows Update                 4                 BEGIN_SYSTEM_C... 17
8/5/2019  08:15:37     Installed PowerShell 7-prev... 5                 BEGIN_SYSTEM_C... APPLICATION_INSTALL

Get-ComputerRestorePoint 會使用 RestorePoint 參數來指定以逗號分隔的序號陣列。

範例 3:顯示系統還原的狀態

此範例會顯示本機計算機上最近系統還原的狀態。

Get-ComputerRestorePoint -LastStatus

The last attempt to restore the computer failed.

Get-ComputerRestorePoint 會使用 LastStatus 參數來顯示最近系統還原的結果。

範例 4:使用表示式轉換 CreationTime

Get-ComputerRestorePoint 會將 CreationTime 輸出為 Windows Management Instrumentation (WMI) 日期和時間字串。

在此範例中,變數會儲存表達式,將 CreationTime 字串轉換成 DateTime 物件。 若要在轉換之前檢視 CreationTime 字串,請使用 ((Get-ComputerRestorePoint).CreationTime)之類的命令。 如需 WMI 日期和時間字串的詳細資訊,請參閱 CIM_DATETIME

$date = @{Label="Date"; Expression={$_.ConvertToDateTime($_.CreationTime)}}
Get-ComputerRestorePoint | Select-Object -Property SequenceNumber, $date, Description

SequenceNumber   Date                 Description
--------------   ----                 -----------
             4   7/30/2019 09:17:24   Windows Update
             5   8/5/2019  08:15:37   Installed PowerShell 7-preview-x64
             6   8/7/2019  12:56:45   Installed PowerShell 6-x64

$date 變數會使用 convertToDateTime 方法 的運算式來儲存哈希表。 表達式會將 CreationTime 屬性值從 WMI 字串轉換成 DateTime 物件。

Get-ComputerRestorePoint 將系統還原點對象傳送至管線。 Select-Object 會使用 Property 參數來指定要顯示的屬性。 針對管線中的每個物件,$date 中的表達式會轉換 CreationTime,並在 Date 屬性中輸出結果。

範例 5:使用 屬性來取得序號

這個範例會使用 SequenceNumber 屬性和陣列索引來取得序號。 輸出只包含序號。

((Get-ComputerRestorePoint).SequenceNumber)[-1]

6

Get-ComputerRestorePoint 使用具有陣列索引的 SequenceNumber 屬性。 -1 的陣列索引會取得數位中最新的序號。

參數

-LastStatus

表示 Get-ComputerRestorePoint 取得最新系統還原作業的狀態。

類型:SwitchParameter
Position:Named
預設值:False
必要:True
接受管線輸入:False
接受萬用字元:False

-RestorePoint

指定系統還原點的序號。 您可以指定單一序號或以逗號分隔的序號陣列。

如果未指定 RestorePoint 參數,Get-ComputerRestorePoint 會傳回所有本機電腦的系統還原點。

類型:Int32[]
Position:0
預設值:All restore points
必要:False
接受管線輸入:False
接受萬用字元:False

輸入

None

您無法將物件從管線向下傳送至 Get-ComputerRestorePoint

輸出

ManagementObject

Get-ComputerRestorePoint 會傳回 SystemRestore 物件,這是 SystemRestore 類別的 Windows Management Instrumentation (WMI) 實例。

當您使用 LastStatus 參數時,Get-ComputerRestorePoint 會傳回字串。

備註

若要在 Windows Vista 和更新版本的 Windows 上執行 Get-ComputerRestorePoint 命令,請使用 [以系統管理員身分執行] 選項開啟 PowerShell。

Get-ComputerRestorePoint 使用 WMI SystemRestore 類別。