A colleague worked hard for one months to finish the design plan, because of his careless, directly from the company's shared file server deleted, can not be recovered. I also tried to build a shared folder, through the Explorer deleted, but also in the Recycle Bin can not find, so as to understand the female man's difficulties.
We usually use the PowerShell remove-item command to delete the file, but also belong to the total deletion. In fact, really, if I can, I would like to Zhaoyuan fast food 6 killers, execute the Remove command, no, direct kill command.
So how do you safely delete files to the Recycle Bin in PowerShell? Obviously you need to invoke the COM component of Windows:
Copy Code code as follows:
$testFile = "Jb51.net"
Dir | Out-file $testFile
$shell = New-object-comobject "Shell.Application"
$item = $shell. Namespace (0). ParseName ((Resolve-path $testFile). Path)
$item. Invokeverb ("delete")
Note the 4th line, be sure to use the absolute path, use relative path may be an error.