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-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
使用 属性 参数指定要显示的属性。 对于管道中的每个对象,$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
。
输出
Get-ComputerRestorePoint
返回 SystemRestore 对象,该对象是 Windows Management Instrumentation (WMI) SystemRestore 类的实例。
使用 LastStatus 参数时,Get-ComputerRestorePoint
返回一个字符串。
备注
若要在 Windows Vista 和更高版本的 Windows 上运行 Get-ComputerRestorePoint
命令,请使用 以管理员 选项打开 PowerShell。
Get-ComputerRestorePoint
使用 WMI SystemRestore 类。