Created
July 8, 2022 02:52
-
-
Save hidsh/d85e92be4c8db2c94cf968f2fcee1ae4 to your computer and use it in GitHub Desktop.
コマンドライン(powershell)で Windows 10 の復元ポイントを作成
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# コマンドライン(powershell)で Windows 10 の復元ポイントを作成 | |
# | |
$comment = Read-Host "コメント" | |
if([string]::IsNullOrEmpty($comment)) { | |
$comment = "変更" | |
} | |
#Write-Output $comment | |
try { | |
Checkpoint-Computer -Description $comment -ErrorAction Stop | |
} | |
catch [System.Management.ManagementException] { | |
Write-Output $_.Exception | |
} | |
finally { | |
# 開いたままにする | |
$host.UI.RawUI.ReadKey() | |
} |
あと、前回復元ポイントを作成して1時間以内に再度作成する場合は下記のようにエラー(例外)が発生して作成できないので注意。
Checkpoint-Computer : アクセスは拒否されました
発生場所 D:\pgm\mk-fukugen-point.ps1:11 文字:2
+ Checkpoint-Computer -Description $comment -ErrorAction Stop
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (:) [Checkpoint-Computer]、ManagementException
+ FullyQualifiedErrorId : GetWMIManagementException,Microsoft.PowerShell.Commands.CheckpointComputerCommand
動いてないっぽい
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
スタートメニューから実行する場合は下のようにショートカットを作って、
C:\ProgramData\Microsoft\Windows\Start Menu\Programs
に入れておく。powershell でこのファイルを走らせるので、ショートカットの
リンク先
の先頭にpowershell
を追加しておくのを忘れずに。