それマグで!

知識はカップより、マグでゆっくり頂きます。 takuya_1stのブログ

習慣に早くから配慮した者は、 おそらく人生の実りも大きい。

PowerShell で確認Y/Nをスキップする

Remove-Item で確認が出る。

例えば、Powershellレジストリを消そうとすると。

レジストリの削除

Remove-Item -LiteralPath 'HKLM:\SOFTWARE\Classes\Directory\background\shell\VSCode' 

確認が表示される。

If you continue, all children will be removed with the item. Are you sure you want to continue? [Y] Yes [A] Yes to All [N] No [L] No to All [S] Suspend [?] Help (default is "Y"):

確認無しで削除を実行

確認が表示されると自動化に困難なので、確認を出さない

Remove-Item -LiteralPath 'HKLM:\SOFTWARE\Classes\Directory\background\shell\VSCode'  -Confirm:$false  -Recurse -Force

コレで、確認無しで削除を実行できる。

-confirm:$falseで「無」確認で実行できる。

Bashなどのスクリプトにある「常にYESと答える。」、PowerShellは、Bashとは違い、「はじめから確認なし」になる。

参考資料

https://stackoverflow.com/questions/4753702/automatic-confirmation-of-deletion-in-powershell