Solved

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

Posted on 2014-01-29
4
319 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Are your AD admin tools letting you down?

Managing Active Directory can get complicated.  Often, the native tools for managing AD are just not up to the task.  The largest Active Directory installations in the world have relied on one tool to manage their day-to-day administration tasks: Hyena. Start your trial today.

Question has a verified solution.

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

A project that enables an administrator to perform actions within a user session context not just at the time of login but any time later on day(s) or week(s) later.
Previously, on our Nano Server Deployment series, we've created a new nano server image and deployed it on a physical server in part 2. Now we will go through configuration.
In this video we show how to create a Resource Mailbox in Exchange 2013. We show this process by using the Exchange Admin Center. Log into Exchange Admin Center.: Navigate to the Recipients >> Resources tab.: "Recipients" is our default selection …
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

752 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