The Windows Recycle Bin is a special folder in Windows, but with some simple PowerShell commands, you can manipulate it easily. The method of manipulation is to create a Shell Application COM object, and manipulate it a technique familiar to VB-Scripters the world over
To get to the recycle bin, you need to do something like this:
$objShell = New-Object -Com Shell.Application
$objFolder = $objShell.Namespace(0xA) # recycle bin!
$objFolderItem = $objFolder.Self
Following on from this, you can explore the recycle bin by entering the following additional commmand:
$objFolderItem.InvokeVerbEx("Explore")
And to delete all the items in the recycle bin, just type:
$objFolderItem.InvokeVerbEx("Empty Recycle &Bin")
You will, in this last case, be asked to confirm deletion so this command is nearly safe! As ever, take care when playing with commands like this!!
1 comment:
Another solution here (https://www.shellandco.net/shared-folder-recycle-bin-clean/) a script that can help on removing items older than a specific duration on a remote shared folder. Useful on a network shared folder that hosts user home folders
Post a Comment