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

后端 未结 7 1006
攒了一身酷
攒了一身酷 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:02

    Here is a shorter version that reduces a bit of work

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

提交回复
热议问题