如何在 Windows PowerShell 中正确使用 Remove-Item -Confirm:$false -Force

How to use Remove-Item -Confirm:$false -Force properly in Windows PowerShell

因此,我正在 PowerShell 中编写此脚本,我需要在 Windows 上删除 APPDATA 中的一些文件。我写了这行代码,但它并没有悄悄地删除该项目。即使在使用 $Confirm:false 之后,它也会要求确认。我该如何解决这个问题?

我的代码:

Get-ChildItem -Path $env:APPDATA\"Microsoft\teams\blob_storage" | Remove-Item -Confirm:$false -Force

我每次 运行 脚本时都会收到这个不需要的确认框:

这是您修改后的代码。希望对你有用。

Get-ChildItem -Path $env:APPDATA\"Microsoft\teams\blob_storage" | Remove-Item -Recurse -Force