Get-ComputerRestorePoint

获取本地计算机上的还原点。

语法

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

说明

Get-ComputerRestorePoint cmdlet 获取本地计算机的系统还原点。 此外,它还可以显示最近尝试还原计算机的状态。

可以使用 Get-ComputerRestorePoint 中的信息来选择还原点。 例如,使用序列号标识 Restore-Computer cmdlet 的还原点。

系统还原点和 Get-ComputerRestorePoint cmdlet 仅在 Windows 10 等客户端操作系统上受支持。

示例

示例 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-ComputerRestorePointCreationTime 输出为 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-ComputerRestorePointSequenceNumber 属性与数组索引配合使用。 -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 类。