$Queuepathfull = "E:\Kerio\MailServer\store\queue" $queuepaths = Get-ChildItem $Queuepathfull $String = "eamil@problem.com" foreach ($Queuepath in $queuepaths) { $allemf = $null $email = $null write-host "Starting on $($queuepath.fullname)" $allemf = get-childitem $Queuepath.fullname -Recurse -Filter '*.emf' foreach ($emf in $allemf) { $email = Get-Content -Encoding Ascii -path $emf.fullname if ($email -match $string) { $Deletecount++ write-host "Deleteing e-mail $($deletecount) ($($emf.name))" Remove-Item $emf.FullName Remove-Item $emf.FullName.replace(".emf",".eml") Remove-Item $emf.FullName.replace(".emf",".env") } } }