Here a few methods of deleting the contents of folders with Powershell. These methods are useful for keeping servers clean and tidy and emptying users recycle bins.
Clear out users recycle bin data based on SID
Import-Module activedirectory
[string]$recycleBinPath = ‘C:\$Recycle.Bin\’
$userSID = ((Get-ADUser chrisa).sid).value
Remove-Item “$recycleBinPath$userSID” -recurse -force
Delete all folders in $Recycle.bin
dir ‘c:\$recycle.bin’ -force|foreach{if($_.name -like “s-*”){rd $_.name -force -recurse}}
Hope these help
No comments yet... Be the first to leave a reply!