【发布时间】:2021-09-10 12:40:18
【问题描述】:
所以,我在 PowerShell 中编写此脚本,我需要在 Windows 上删除 APPDATA 中的一些文件。我写了这行代码,它并没有默默地删除该项目。即使在使用 $Confirm:false 之后,它也会要求确认。我该如何解决这个问题?
我的代码:
Get-ChildItem -Path $env:APPDATA\"Microsoft\teams\blob_storage" | Remove-Item -Confirm:$false -Force
每次我运行脚本时都会收到这个不需要的确认框:
【问题讨论】:
-
因为您尝试删除的项目中包含子项目,您需要在
-Force之后提供-Recurse开关,这将允许您在没有提示的情况下删除子项目 -
这行得通。谢谢
标签: windows powershell powershell-2.0 powershell-3.0 powershell-4.0