小编Pat*_*key的帖子

如何删除 PowerShell 说不存在的文件?

我将我的 Google Drive 添加到我的 OneDrive 并在其中包含一个包含无效名称 (con.mp3) 的文件。当我尝试删除文件(及其所在的目录)时,我收到“无效的文件句柄”。所以我尝试以管理员身份使用 PowerShell 删除它。

下面是目录列表显示的文件,结果Remove-Itemdel

PS> dir

    Directory: C:\Users\Patrick\OneDrive\Google Drive\CW\CW.15WPM.VeryShortWords


Mode                LastWriteTime         Length Name
----                -------------         ------ ----
-a----        1/13/2018  11:49 AM         117069 con.mp3


PS> Remove-Item * -Force
Remove-Item : An object at the specified path C:\Users\Patrick\OneDrive\Google
Drive\CW\CW.15WPM.VeryShortWords\con.mp3 does not exist.
At line:1 char:1
+ Remove-Item * -Force
+ ~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidArgument: (:) [Remove-Item], PSArgumentException
    + FullyQualifiedErrorId : Argument,Microsoft.PowerShell.Commands.RemoveItemCommand

PS> del *.*
del : An object at the …
Run Code Online (Sandbox Code Playgroud)

powershell delete-file

5
推荐指数
1
解决办法
6371
查看次数

标签 统计

delete-file ×1

powershell ×1