Advertisement
Guest User

Untitled

a guest
Oct 9th, 2015
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.41 KB | None | 0 0
  1. cd C:\Temp\!
  2.  
  3. function Get-LogSize($p) {
  4. return (Get-ChildItem $p | Measure-Object -property length -sum).Sum;
  5. }
  6.  
  7. Get-ChildItem |
  8. Sort-Object -Property CreationTime |
  9. Select-Object Name,@{Name="Size";Expression={Get-LogSize($_)}} |
  10. ##Group-Object Size > ..\after.txt
  11. Group-Object Size |
  12. ForEach-Object { $_.Group | Select-Object -Skip 1 | ForEach-Object { Remove-Item $_.Name -Force -Recurse } }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement