Created
April 3, 2018 13:59
-
-
Save HamousOnWheels/2cfdd2ef5ba1939a2bbf6480b8d1b251 to your computer and use it in GitHub Desktop.
Clear recycle bin items older than 6 months
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| $Shell = New-Object -ComObject Shell.Application | |
| $Global:Recycler = $Shell.NameSpace(0xa) | |
| foreach($item in $Recycler.Items()) | |
| { | |
| $DeletedDate = $Recycler.GetDetailsOf($item,2) -replace "\u200f|\u200e","" | |
| $dtDeletedDate = get-date $DeletedDate | |
| If($dtDeletedDate -lt (Get-Date).AddMonths(-6)) | |
| { | |
| Remove-Item -Path $item.Path -Confirm:$false -Force -Recurse | |
| }#EndIF | |
| }#EndForeach item |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment