{"id":84,"date":"2007-03-02T12:00:00","date_gmt":"2007-03-02T20:00:00","guid":{"rendered":"http:\/\/testblog.sapien.com\/index.php\/2007\/03\/02\/purge-recycle-bin\/"},"modified":"2007-03-02T12:00:00","modified_gmt":"2007-03-02T20:00:00","slug":"purge-recycle-bin","status":"publish","type":"post","link":"https:\/\/dev.sapien.com\/blog\/2007\/03\/02\/purge-recycle-bin\/","title":{"rendered":"Purge Recycle Bin"},"content":{"rendered":"<p>The <a href=\"\/current\/2007\/2\/26\/fast-furious-powershell-get-recycle-size.html\">other day<\/a> I showed how to find out how much space was being used by the recycle bin. To clear the folder you can use an expression that takes the result of Get-Child-item and pipes it to Remove-Item.&nbsp; Here&#8217;s an example:<\/p>\n<p><font size=\"2\" face=\"Lucida Console\" color=\"#0000ff\" style=\"color: rgb(0, 0, 255);\">Get-ChildItem e:\\temp\\testme -recurse | remove-item -recurse -whatif<\/font><\/p>\n<p>I&#8217;m using the -WhatIf parameter so verify what would happen. This is a good habit when performing destructive operations. You may need to use -force to overcome any restrictions like a read-only file. You still need permission to delete the file.&nbsp; Using -force won&#8217;t change any permissions.<\/p>\n<p>Because the Recycle folder is hidden, you&#8217;ll want to use an expression like this:<\/p>\n<p><font size=\"2\" face=\"Lucida Console\" color=\"#0000ff\" style=\"color: rgb(0, 0, 255);\">Get-ChildItem c:\\recycler -force -recurse | remove-item -recurse -force -whatif<\/font><\/p>\n<p>This will show what will be deleted. To carry out the dirty deed:<\/p>\n<p><font size=\"2\" face=\"Lucida Console\" color=\"#0000ff\" style=\"color: rgb(0, 0, 255);\">Get-ChildItem c:\\recycler -force -recurse | remove-item -recurse -force<\/font><\/p>\n<p>You might see an error message about failing to find part of a path, but you should be able to ignore this message. I strongly encourage you to test all of this on a non-production system so that you thoroughly understand how these cmdlets and expressions work.<\/p>\n<div class=\"wlWriterSmartContent\" id=\"0767317B-992E-4b12-91E0-4F059A8CECA8:c7a678e5-4669-457b-ae63-ed52dda4d73a\" style=\"margin: 0px; padding: 0px; display: inline;\">del.icio.us tags: <a href=\"http:\/\/del.icio.us\/popular\/PowerShell\" rel=\"tag\">PowerShell<\/a>, <a href=\"http:\/\/del.icio.us\/popular\/Remove-Item\" rel=\"tag\">Remove-Item<\/a>, <a href=\"http:\/\/del.icio.us\/popular\/Get-ChildItem\" rel=\"tag\">Get-ChildItem<\/a>, <a href=\"http:\/\/del.icio.us\/popular\/RecyleBin\" rel=\"tag\">RecyleBin<\/a>, <a href=\"http:\/\/del.icio.us\/popular\/Scripting\" rel=\"tag\">Scripting<\/a><\/div>\n<p> <\/p>\n<div class=\"wlWriterSmartContent\" id=\"0767317B-992E-4b12-91E0-4F059A8CECA8:df28adcb-091e-4058-a6bd-03322eb3be18\" style=\"margin: 0px; padding: 0px; display: inline;\">Technorati tags: <a href=\"http:\/\/technorati.com\/tags\/PowerShell\" rel=\"tag\">PowerShell<\/a>, <a href=\"http:\/\/technorati.com\/tags\/Remove-Item\" rel=\"tag\">Remove-Item<\/a>, <a href=\"http:\/\/technorati.com\/tags\/Get-ChildItem\" rel=\"tag\">Get-ChildItem<\/a>, <a href=\"http:\/\/technorati.com\/tags\/RecyleBin\" rel=\"tag\">RecyleBin<\/a>, <a href=\"http:\/\/technorati.com\/tags\/Scripting\" rel=\"tag\">Scripting<\/a><\/div>\n","protected":false},"excerpt":{"rendered":"<p>The other day I showed how to find out how much space was being used by the recycle bin. To clear the folder you can use an expression that takes the result of Get-Child-item and pipes it to Remove-Item.<\/p>\n","protected":false},"author":3,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"footnotes":""},"categories":[25],"tags":[],"class_list":["post-84","post","type-post","status-publish","format-standard","hentry","category-windows-powershell"],"jetpack_featured_media_url":"","_links":{"self":[{"href":"https:\/\/dev.sapien.com\/blog\/wp-json\/wp\/v2\/posts\/84","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/dev.sapien.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/dev.sapien.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/dev.sapien.com\/blog\/wp-json\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/dev.sapien.com\/blog\/wp-json\/wp\/v2\/comments?post=84"}],"version-history":[{"count":0,"href":"https:\/\/dev.sapien.com\/blog\/wp-json\/wp\/v2\/posts\/84\/revisions"}],"wp:attachment":[{"href":"https:\/\/dev.sapien.com\/blog\/wp-json\/wp\/v2\/media?parent=84"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/dev.sapien.com\/blog\/wp-json\/wp\/v2\/categories?post=84"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/dev.sapien.com\/blog\/wp-json\/wp\/v2\/tags?post=84"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}