可以使用 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
声明:本站所有文章,如无特殊说明或标注,均为本站原创发布。任何个人或组织,在未征得本站同意时,禁止复制、盗用、采集、发布本站内容到任何网站、书籍等各类媒体平台。如若本站内容侵犯了原著者的合法权益,可联系我们进行处理。