Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # https://www.reddit.com/r/PowerShell/comments/4a64bv/daily_powershell_challenge_31216/
- function Get-DuplicateDownloads ($comp = $env:COMPUTERNAME) {
- dir \\$comp\c$\users -Directory | ? {test-path "$($_.FullName)\downloads"} | select -exp basename | % {
- dir \\$comp\c$\users\$_\downloads\* -file | group {$_.basename -replace ' \([0-9]+\)$'} | ? count -gt 1 | % {
- $_.group | group {(Get-FileHash $_.fullname).hash} | ? count -gt 1 | % {
- $_.group | sort name -Descending | select -Skip 1 -exp fullname
- }
- }
- }
- }
- Get-DuplicateDownloads -comp 'workstation2' | Remove-Item -WhatIf
Add Comment
Please, Sign In to add comment