Get-ComputerRestorePoint
ローカル コンピューター上の復元ポイントを取得します。
構文
ID (既定)
Get-ComputerRestorePoint
[[-RestorePoint] <Int32[]>]
[<CommonParameters>]
LastStatus
Get-ComputerRestorePoint
-LastStatus
[<CommonParameters>]
説明
Get-ComputerRestorePoint コマンドレットは、ローカル コンピューターのシステム復元ポイントを取得します。 また、コンピューターを復元する最新の試行の状態を表示できます。
Get-ComputerRestorePoint の情報を使用して、復元ポイントを選択できます。 たとえば、シーケンス番号を使用して、Restore-Computer コマンドレットの復元ポイントを識別します。
システム復元ポイントと Get-ComputerRestorePoint コマンドレットは、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 では、Property パラメーターを使用して、表示するプロパティを指定します。 パイプライン内の各オブジェクトについて、$date の式は CreationTime を変換し、結果を Date プロパティに出力します。
例 5: プロパティを使用してシーケンス番号を取得する
この例では、SequenceNumber プロパティと配列インデックスを使用してシーケンス番号を取得します。 出力にはシーケンス番号のみが含まれます。
((Get-ComputerRestorePoint).SequenceNumber)[-1]
6
Get-ComputerRestorePoint は、配列インデックスを持つ SequenceNumber プロパティを使用します。
-1 の配列インデックスは、配列内の最新のシーケンス番号を取得します。
パラメーター
-LastStatus
Get-ComputerRestorePoint が最新のシステム復元操作の状態を取得することを示します。
パラメーターのプロパティ
| 型: | SwitchParameter |
| 規定値: | False |
| ワイルドカードのサポート: | False |
| DontShow: | False |
パラメーター セット
LastStatus
| 配置: | Named |
| 必須: | True |
| パイプラインからの値: | False |
| プロパティ名別のパイプラインからの値: | False |
| 残りの引数からの値: | False |
-RestorePoint
システム復元ポイントのシーケンス番号を指定します。 1 つのシーケンス番号またはシーケンス番号のコンマ区切りの配列を指定できます。
RestorePoint パラメーターが指定されていない場合、Get-ComputerRestorePoint はローカル コンピューターのすべてのシステム復元ポイントを返します。
パラメーターのプロパティ
| 型: | Int32[] |
| 規定値: | All restore points |
| ワイルドカードのサポート: | False |
| DontShow: | False |
パラメーター セット
ID
| 配置: | 0 |
| 必須: | False |
| パイプラインからの値: | False |
| プロパティ名別のパイプラインからの値: | False |
| 残りの引数からの値: | False |
CommonParameters
このコマンドレットでは、一般的なパラメーター -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 クラスを使用します。