is there a way to get all the info of the recycle bin of multiple servers (name of file, size) and then later have an option to clear all the files inside it? I just want to know how much space I am deleting first. If possible I want to put all the server names in a txt file.<\/p>","upvoteCount":4,"answerCount":8,"datePublished":"2018-07-31T05:22:08.000Z","author":{"@type":"Person","name":"a2jr","url":"https://community.spiceworks.com/u/a2jr"},"acceptedAnswer":{"@type":"Answer","text":"
Closer <\/p>\n
You are getting the error because the module/function only exists on your local computer and not on the remote servers.<\/p>\n
So you need to send it to the remote servers in some way, luckily it is quite small so no big deal. You can send the entire function to the remote server:<\/p>\n
$sb = {\n function Get-RecycleBin \n {\n (New-Object -ComObject Shell.Application).NameSpace(0x0a).Items() |\n\t Select-Object Name, Size, Path\n }\n Get-RecycleBin\n}\nInvoke-Command -ComputerName $computer -ScriptBlock $sb \n\n<\/code><\/pre>\nOf course this won’t solve the problem of how to clean up the recycle bin as the remote servers will need PS 5 installed to user the cmdlet that Thomas mentioned.<\/p>","upvoteCount":0,"datePublished":"2018-08-03T09:46:11.000Z","url":"https://community.spiceworks.com/t/recyle-bin-query-and-clear-it/665045/7","author":{"@type":"Person","name":"psophos","url":"https://community.spiceworks.com/u/psophos"}},"suggestedAnswer":[{"@type":"Answer","text":"
is there a way to get all the info of the recycle bin of multiple servers (name of file, size) and then later have an option to clear all the files inside it? I just want to know how much space I am deleting first. If possible I want to put all the server names in a txt file.<\/p>","upvoteCount":4,"datePublished":"2018-07-31T05:22:08.000Z","url":"https://community.spiceworks.com/t/recyle-bin-query-and-clear-it/665045/1","author":{"@type":"Person","name":"a2jr","url":"https://community.spiceworks.com/u/a2jr"}},{"@type":"Answer","text":"
If you are using PowerShell 5.0 or higher, you can use the Clear-RecycleBin cmdlet. See: Clear-RecycleBin (Microsoft.PowerShell.Management) - PowerShell | Microsoft Learn<\/a> for details.<\/p>\nAs for querying the recycle bin, you could try this: https://gallery.technet.microsoft.com/scriptcenter/Get-RecycleBin-shows-the-085d12b0<\/a> although I have not tested it.<\/p>","upvoteCount":2,"datePublished":"2018-07-31T07:17:04.000Z","url":"https://community.spiceworks.com/t/recyle-bin-query-and-clear-it/665045/2","author":{"@type":"Person","name":"DoctorDNS","url":"https://community.spiceworks.com/u/DoctorDNS"}},{"@type":"Answer","text":"Take a peak at this. They have written a function to address querying of the Recycle bin.<\/p>\n
https://www.jaapbrasser.com/clear-recyclebin-new-powershell-5-0-cmdlet-available-in-windows-10/<\/a><\/p>","upvoteCount":0,"datePublished":"2018-07-31T14:51:04.000Z","url":"https://community.spiceworks.com/t/recyle-bin-query-and-clear-it/665045/3","author":{"@type":"Person","name":"brandonschwebs7408","url":"https://community.spiceworks.com/u/brandonschwebs7408"}},{"@type":"Answer","text":"Thanks tfl and Brando_Blain. Im still in the query of recycle bin and attached is the script that I made (dont laugh please). Unfortunately, that script is querying the recycle bin of my laptop, not the servers in the txt file. Can you educate me on my mistake please?<\/p>\n