删除文件到回收站

1 $testFile="pstips.net"
2 dir | Out-File $testFile
3 $shell = new-object -comobject "Shell.Application"
4 $item = $shell.Namespace(0).ParseName( (Resolve-Path $testFile).Path)
5 $item.InvokeVerb("delete")

注意第4行,一定要用绝对路径,使用相对路径可能会报错

From:http://www.pstips.net/remove-file-to-recycle-bin.html

原文地址:https://www.cnblogs.com/dreamer-fish/p/3928638.html