Solved

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

Posted on 2014-01-29
4
308 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

Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
POP3 connectivity issues (SSL related perhaps?) 4 30
Replacing Domain Controller 15 31
Unified EndPoint Management 1 26
exchange, outlook 20 31
This process describes the steps required to Import and Export data from and to .pst files using Exchange 2010. We can use these steps to export data from a user to a .pst file, import data back to the same or a different user, or even import data t…
This article explains how to install and use the NTBackup utility that comes with Windows Server.
In this video we show how to create an Address List 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 Organization >> Ad…
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…

803 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