Get-ComputerRestorePoint
取得本機電腦上的還原點。
語法
ID (預設值)
Get-ComputerRestorePoint
[[-RestorePoint] <Int32[]>]
[<CommonParameters>]
LastStatus
Get-ComputerRestorePoint
-LastStatus
[<CommonParameters>]
Description
Get-ComputerRestorePoint Cmdlet 會取得本機計算機的系統還原點。 而且,它可以顯示最近嘗試還原計算機的狀態。
您可以使用 Get-ComputerRestorePoint 的資訊來選取還原點。 例如,使用序號來識別 Restore-Computer Cmdlet 的還原點。
只有 Windows 10、Windows 7、Windows Vista 和 Windows XP 等用戶端作業系統才支援系統還原點和 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
Get-ComputerRestorePoint 將系統還原點對象傳送至管線。
Select-Object 會使用 Property 參數來指定要顯示的屬性。 針對管線中的每個物件,$date 中的表達式會轉換 CreationTime,並在 Date 屬性中輸出結果。
範例 5:使用 屬性來取得序號
這個範例會使用 SequenceNumber 屬性和陣列索引來取得序號。 輸出只包含序號。
((Get-ComputerRestorePoint).SequenceNumber)[-1]
6
Get-ComputerRestorePoint 使用具有陣列索引的 SequenceNumber 屬性。
-1 的陣列索引會取得數位中最新的序號。
參數
-LastStatus
表示 Get-ComputerRestorePoint 取得最新系統還原作業的狀態。
參數屬性
| 類型: | SwitchParameter |
| 預設值: | False |
| 支援萬用字元: | False |
| 不要顯示: | False |
參數集
LastStatus
| Position: | Named |
| 必要: | True |
| 來自管線的值: | False |
| 來自管線按屬性名稱的值: | False |
| 來自剩餘引數的值: | False |
-RestorePoint
指定系統還原點的序號。 您可以指定單一序號或以逗號分隔的序號陣列。
如果未指定 RestorePoint 參數,Get-ComputerRestorePoint 會傳回所有本機電腦的系統還原點。
參數屬性
| 類型: | Int32[] |
| 預設值: | All restore points |
| 支援萬用字元: | False |
| 不要顯示: | False |
參數集
ID
| Position: | 0 |
| 必要: | False |
| 來自管線的值: | False |
| 來自管線按屬性名稱的值: | False |
| 來自剩餘引數的值: | False |
CommonParameters
此 Cmdlet 支援一般參數:-Debug、-ErrorAction、-ErrorVariable、-InformationAction、-InformationVariable、-OutBuffer、-OutVariable、-PipelineVariable、-ProgressAction、-Verbose、-WarningAction 和 -WarningVariable。 如需詳細資訊,請參閱 about_CommonParameters。
輸入
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 類別。