Mailbox Script

Hi Admin -

I'm in need for an Exchange 2010 PS script that will provide me with the following
1. script will check specific databases in our exchange environment
2. Send an email to those users whose mailboxes are 80% full
3. The email message will contains the following:
     a. Subject
     b. Body message
     c.  Attachment report in PDF that contains the Get-MailboxFolderStatistics | select name, foldersize, itemsinfolder

The report will inform the user they are approaching the size limit and it will also help them identify which folder has the most items and the folder size.

Please help -

Sincerely,
John
johnmerrick99Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

sirbountyCommented:
Hmm - I was with you until the PDF attachment...
Maybe someone else has some ideas on that one.
0
AmitIT ArchitectCommented:
No script or pdf required for your task. You need to apply Quota limits. Review this
https://technet.microsoft.com/en-us/library/bb232173(v=exchg.141).aspx
0
Will SzymkowskiSenior Solution ArchitectCommented:
The below script will do most of what you are looking for. only differences is that it is looking at mailboxes with a StorageLimitStatus of "Warning" and the attachment is a CSV rather than PDF.

$Database = "MBDB.domain.com"
$SMTPServer = "HTServer.domain.com"
$Subject = "Type your Subject here!"
$Body = "Type your body here"
$Mailboxes = Get-Mailbox -ResultSize "unlimited" -Database $Database | Get-MailboxStatistics | ? { ($_.StorageLimitStatus -eq "Warning") }

ForEach ($Mailbox in $Mailboxes)
    {
       $Email = Get-Mailbox -Identity $Mailbox
       $Attachment = "c:\temp\$Mailbox.csv"

       $Data = Get-Mailbox -Identity $Mailbox | Get-MailboxFolderStatistics | select Name, FolderSize, ItemsIfFolder
       $Data | Export-Csv $Attachment -NTI

       Send-MailMessage -To $Email.PrimarySmtpAddress -Subject $Subject -Body $Body -Attachments $Attachment

       Remove-Item $Attachment -confirm:$false

}

Open in new window


Will.
0
Has Powershell sent you back into the Stone Age?

If managing Active Directory using Windows Powershell® is making you feel like you stepped back in time, you are not alone.  For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why.

johnmerrick99Author Commented:
Hi All -

Sorry for the delayed response. I had a family emergency the last few days.
Thank you for the suggestions and the quick responses.  

To Will, Thank you for the script. I believe that's exactly what I'm looking for. I will be in the office tomorrow morning and will test it. But it looks good.  One quick question will,
1. is there a way in your script to add a line to send an email to the exchange admin group of all the users who received the email of warning?
2. Also to add a log to the script - so we know if it ran successfully or if it failed?

Again, thank you so much for your time and quick response. I'm learning powershell right now. so this is a good start for me. thanks again.
0
Will SzymkowskiSenior Solution ArchitectCommented:
I have modified my scripted above to include both addtional steps...

$ExchangeGroup = "ExchangeAdmins@domain.com"
$LogFile = "C:\LogFile.txt"
$Database = "MBDB.domain.com"
$SMTPServer = "HTServer.domain.com"
$Subject = "Type your Subject here!"
$Body = "Type your body here"
$Mailboxes = Get-Mailbox -ResultSize "unlimited" -Database $Database | Get-MailboxStatistics | ? { ($_.StorageLimitStatus -eq "Warning") }

$Mailboxes | Out-File $LogFile

ForEach ($Mailbox in $Mailboxes)
    {      

       $Email = Get-Mailbox -Identity $Mailbox
       $Attachment = "c:\temp\$Mailbox.csv"

       $Data = Get-Mailbox -Identity $Mailbox | Get-MailboxFolderStatistics | select Name, FolderSize, ItemsIfFolder
       $Data | Export-Csv $Attachment -NTI

       Send-MailMessage -To $Email.PrimarySmtpAddress, $ExchangeGroup -Subject $Subject -Body $Body -Attachments $Attachment

       Remove-Item $Attachment -confirm:$false

}

Open in new window


I have added a variable called ExchangeGroup and LogFile. Just update those fields with the correct data from your environment.

Thats it.

Will.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
johnmerrick99Author Commented:
Thank you for the quick responses and the awesome script. You were awesome. Keep the good work of helping others. Much appreciated.

John
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Exchange

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.