可以使用 Remove-Item 删除包含的项,但如果项包含任何其他内容,系统将提示你确认该删除。 例如,如果尝试删除包含其他项的文件夹 C:/temp/DeleteMe
,则在删除该文件夹之前 Windows PowerShell 会提示你确认:
Remove-Item -Path C:/temp/DeleteMe
Confirm
The item at C:/temp/DeleteMe has children and the -recurse parameter was not
specified. 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"):
如果不希望系统针对每个包含的项都提示你,则指定 Recurse 参数:
Remove-Item -Path C:/temp/DeleteMe -Recurse
原创文章,作者:ItWorker,如若转载,请注明出处:https://blog.ytso.com/tech/pnotes/264552.html