Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $GetDuplicates = {
- $HashList = New-Object System.Collections.ArrayList
- $Duplicates = New-Object System.Collections.ArrayList
- (Measure-Command {
- foreach ($item in (Get-ChildItem -File)) {
- if (!$HashList.Contains( ($Hash = (Get-FileHash $item.FullName -Algorithm MD5).Hash) )) {
- $HashList.Add($Hash) >$null
- } else {
- $Duplicates.Add($_.FullName) >$null
- }
- }
- }).ToString('m\:ss\.fff')
- }
- for ($i = 1; $i -lt 3; $i++) {
- "`n Iteration $i"
- Set-MpPreference -DisableRealtimeMonitoring $false
- Write-Host ' Real-time protection enabled :' -NoNewline
- & $GetDuplicates
- Set-MpPreference -DisableRealtimeMonitoring $true
- Write-Host ' Real-time protection disabled:' -NoNewline
- & $GetDuplicates
- }
Advertisement
Add Comment
Please, Sign In to add comment