• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 539
  • Last Modified:

power shell exchange filter Deleted Items

Hello!!
I’m just looking for some PowerShell help on exchange. What I am trying to find out is who have more than 1,000 items in their deleted folder in outlook.
I can find out the sizes of the deleted items folder with:

$mailFrom = "housekeeping@...."
$mailto = "tes@..."
$smtpServer = "mail.??.local"
$warninglimit = 1000
Write-Host "warninglimit: $($warninglimit) " -ForegroundColor Green
Get-MailboxStatistics -server EX1 | ft displayName,deletedItemCount,@{l="TotalDeletedItemSize";e={$_.totalDeletedItemSize.value.toMB()}}

 I then need to be able to filter the result from there.

-Filter { DeletedItemCount -ge $warninglimit }

I’m just unsure how to put this all together!

The reason for this is eventually it will be an automated script (once a week) that e-mails users who have more than 1,000 items and recommending that they clear out their deleted folder. Then once this is under control I will implement a exchange policy that automatically cleans up their deleted items on their behalf.

Thank you !



0
stephenHenderson123
Asked:
stephenHenderson123
2 Solutions
 
MNH1966Commented:
Don't have an Exchange server handy to test right now, but this should get you in the right direction:

Get-Mailbox | Get-MailboxFolderStatistics -folderscope 'Deleted Items' | Where-Object ($_.ItemsInFolder -gt 1000) | ft displayName,deletedItemCount
0
 
AkhaterCommented:
here you go
$mailFrom = "housekeeping@...."
$mailto = "tes@..."
$smtpServer = "mail.??.local"
$warninglimit = 100
Write-Host "warninglimit: $($warninglimit) " -ForegroundColor Green
Get-MailboxStatistics -server ex1 | ? {$_.DeletedItemCount -gt $warninglimit} | ft displayName,deletedItemCount,@{l="TotalDeletedItemSize";e={$_.totalDeletedItemSize.value.toMB()}}

Open in new window

0
 
stephenHenderson123Author Commented:
Superb thank you

i will post the whole script once complete, might be useful to someone in the future !!
0

Featured Post

What Security Threats Are We Predicting for 2018?

Cryptocurrency, IoT botnets, MFA, and more! Hackers are already planning their next big attacks for 2018. Learn what you might face, and how to defend against it with our 2018 security predictions.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now