I invite you to follow me on Twitter and Facebook. (New-Object -ComObject Shell.Application).NameSpace(0x0a).Items() | Of course, I want to verify that the recycle bin is empty, so I use the following code to see that the recycle bin is empty: New-Object -ComObject Shell.Application).NameSpace(0x0a).Items() | Now it is time to see if they exist in the Recycle bin. Now I want to delete all of the files that are in my temporary folder:ĭir $(::GetTempPath()) | Remove-Item -Recurse Now, I am going to look at the Temporary older to ensure that I have the temporary files there: First I will create 25 temporary files (using the PowerShell 5 New-TemporaryFile cmdlet): So I want to create some temporary files and then delete them. But now we have a way cool Windows PowerShell cmdlet to empty the recycle bin. In the past, I have written all kinds of scripts to do this … including some in VBScript that even invoked SendKeys to deal with a user confirmation prompt that I could not get around. I would like to do something more regular, so that when I need a deleted file, it is more easily found. Needless to say, this is an ad hoc operation. So, on a regular basis I empty the recycle bin – often when I am on a conference call that is dragging on, or when I am faced with writers block on some blog article. However, when the recycle bin takes up over a gigabyte of space on my hard drive, and when it contains tens of thousands of files, its uselessness quickly outweighs its utility. It gives me a chance to say, “woops!” and then go get that file that I mis-moused. A PowerShell cmdlet to empty the recycle bin It is time to shed some light on what I am calling the Windows PowerShell 5.0 stealth features. AND, if you have Windows 10 (and more than 270,000,000 people are running Windows 10) then you already have Windows PowerShell 5.0. In fact, there is lots and lots of stuff in Windows PowerShell 5.0 that have been overshadowed by all the hoopla. DSC rocks! Even on Windows PowerShell 4.0 DSC was great, but on Windows PowerShell 5.0 it is even better.īut … and this is huge … but, there is so much more in Windows PowerShell 5.0 than simply improvements to DSC. It seems that now days when I talk to someone about Windows PowerShell 5.0 they get all excited and go on and on about Desired State Configuration (DSC). Summary: Microsoft Scripting Guy Ed Wilson talks about using Windows PowerShell 5.0 to empty the recycle bin on Windows 10
0 Comments
Leave a Reply. |