How do I move a file to the Recycle Bin using PowerShell?

后端 未结 7 1001
攒了一身酷
攒了一身酷 2020-12-07 20:19

By default when you delete a file using PowerShell it\'s permanently deleted.

I would like to actually have the deleted item go to the recycle bin just like I would

7条回答
  •  陌清茗
    陌清茗 (楼主)
    2020-12-07 21:10

    It works in PowerShell pretty much the same way as Chris Ballance's solution in JScript:

     $shell = new-object -comobject "Shell.Application"
     $folder = $shell.Namespace("")
     $item = $folder.ParseName("")
     $item.InvokeVerb("delete")
    

提交回复
热议问题