Created
February 7, 2017 10:10
-
-
Save anonymous/93a524a03bfa5e7461854a5387dc1014 to your computer and use it in GitHub Desktop.
This file contains 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
#Remove-MailQueueObjects.ps1 | |
$Path = "D:\tst" | |
$AllFiles = New-Object System.Collections.ArrayList | |
$AllFiles = Get-ChildItem -Recurse -Path $Path -File -verbose -Filter "*.eml" | |
$AllFiles.Count | |
While(($AllFiles | Select-Object -Last 10).Count -gt 0){ | |
$Scope = $AllFiles | Select-Object -Last 100 | |
Foreach($File in $Scope){ | |
$FileContent = Get-Content -Path $File.FullName | |
if($FileContent.Contains("TextString")){ | |
$File.FullName | Remove-Item -Force | |
"$($File.Directory)\$($File.BaseName).metadata" | Remove-Item -Force | |
} | |
$AllFiles.Remove($File) | |
} | |
$Scope.Count | |
$AllFiles.Count | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment