Solved

need a script that will email me when items in user1 mailbox inbox hits over 100

Posted on 2014-01-29
4
306 Views
Last Modified: 2014-02-03
im looking for a script that will send me an email when the items in user1 inbox hits over 100
im using exchange 2010 sp1
0
Comment
Question by:dougdog
  • 2
  • 2
4 Comments
 
LVL 7

Expert Comment

by:flaphead_com
ID: 39818567
hope this helps.

Start by getting the users mailbox and the mailbox folder stats, where the folderpath is \Inbox

The is the ItemsInFolder is greater than 100, send an email

$User    = "user smtp"
$Items   = 100
$mailbox = get-mailbox $user | Get-MailboxFolderStatistics | Where {$_.FolderPath -eq "/Inbox"}
If($mailbox.ItemsInFolder -gt $items){
  $emailFrom  = "<from email address>"
  $emailto    = "<to email address>"
  $msgSubject = "$user Exceeds $items in inbox"
  $msgBody    = "$user has " + $mailbox.ItemsInFolder + " in inbox"
  $message    = New-Object Net.Mail.MailMessage($emailFrom, $emailto, $msgsubject, $msgbody)
  $smtp       = New-Object Net.Mail.SmtpClient("<smtp relay>")
  $smtp.Send($message)
  Write-Host "Email Sent"
}
0
 

Author Comment

by:dougdog
ID: 39820425
will i just save this asa *.ps1
then schedule it?
0
 
LVL 7

Accepted Solution

by:
flaphead_com earned 500 total points
ID: 39821611
Aye, so save it a .ps1 and try it first, then you can create a schedule task.

What I like to do is create a cmd file that the scheduled task references and in the cmd have:

powershell <location of script.ps1?
0
 

Author Closing Comment

by:dougdog
ID: 39829245
perfect many thanks
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Scam emails are a huge burden for many businesses. Spotting one is not always easy. Follow our tips to identify if an email you receive is a scam.
Find out what you should include to make the best professional email signature for your organization.
In this video we show how to create a Contact in Exchange 2013. We show this process by using the Exchange Admin Center. Log into Exchange Admin Center.: First we need to log into the Exchange Admin Center. Navigate to the Recipients >> Contact ta…
In this video we show how to create an email address policy in Exchange 2013. We show this process by using the Exchange Admin Center. Log into Exchange Admin Center.:  First we need to log into the Exchange Admin Center. Navigate to the Mail Flow…

910 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

23 Experts available now in Live!

Get 1:1 Help Now