Powershell to find the size of Spam Mails folders in the Exchange mailbox

Below script can be used to find the size of spam  Mails folder in the User mailbox for the given list of users. Export list of users from the server throught below command and input into the Name.txt and Execute 

Get-mailbox | Where{$_.Servername -eq “Servername”} | select-object Alias > c:\Names.txt

 
$UserList = Get-Content “C:\Names.txt”
foreach($user in $UserList)
{
     $Spamsize = get-mailboxfolderstatistics $user | Where {$_.Name -match “Spam”}  | select  FolderAndSubfolderSize
     $output = $user + ” ” + $spamsize.FolderAndSubfolderSize/1mb
     Write-output $output 
}

One thought on “Powershell to find the size of Spam Mails folders in the Exchange mailbox

  1. Its like you read my mind! You appear to understand so
    much about this, such as you wrote the ebook in it or something.
    I believe that you simply can do with some p.c. to power
    the message home a bit, but instead of that, that is great blog.
    A great read. I’ll certainly be back.

Leave a reply to search Cancel reply