Get-ComputerRestorePoint

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

Syntax

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

Description

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

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

只有 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 取得最新系統還原作業的狀態。

Type:SwitchParameter
Position:Named
Default value:False
Required:True
Accept pipeline input:False
Accept wildcard characters:False

-RestorePoint

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

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

Type:Int32[]
Position:0
Default value:All restore points
Required:False
Accept pipeline input:False
Accept wildcard characters:False

輸入

None

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

輸出

ManagementObject

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

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

備註

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

Get-ComputerRestorePoint 會使用 WMI SystemRestore 類別。