Report Exch 2007
Hello, I use Exchange 2007: I have a script that generates me a nice report thanks to you and the forum. I would need to add an execption and I do not manage to do it. I fact, when some users who leave the company and they are moved to another OU which is: company.intra/Company/Old/Users/Graig. After 3 to 5 weeks those accounts are automaticaly deactivated on the EMC. But when the report is sent to my managers, those accounts appears and I would like to remove them by creating an exeption. Here is the script that I am using: function SendMail($Recipient) { $SmtpClient = new-object system.net.mail.smtpClient $MailMessage = New-Object system.net.mail.mailmessage $SmtpClient.Host = "server" $mailmessage.from = "admin-graig@company.com" $mailmessage.To.add("$Recipient") $mailmessage.Subject = "[company] Mailbox Statistics - $date" $mailmessage.IsBodyHTML = $true $mailmessage.Body = $body #add attachment $mailattachment = new-object System.Net.Mail.Attachment($attachment) $mailmessage.attachments.add($mailattachment) $smtpclient.Send($mailmessage) } $date = $(get-date).GetDateTimeFormats()[6] $a = "<style>" $a = $a + "BODY{background-color:#FFFFFF;}" $a = $a + "TABLE{border-width: 1px;border-style: solid;border-color: black;border-collapse: collapse;}" $a = $a + "TH{border-width: 1px;padding: 0px;border-style: solid;border-color: black;background-color:#FFFF99}" $a = $a + "TD{border-width: 1px;padding: 0px;border-style: solid;border-color: black;background-color:#FFFF99}" $a = $a + "</style>" Get-MailboxStatistics | Sort-Object TotalItemSize -Descending | ConvertTo-HTML -head $a -property DisplayName, SamAccountName @{l="TotalItemSize(KB)";expression={$_.TotalItemSize.Value.ToKB()}},ItemCount | Out-File c:\scripts\mailboxes.htm $Recipient = "graig@company.com, admin-graig@company.com" $mbxcount = (gc c:\scripts\mailboxes.htm).count -14 $body += "Total =mailbox count is $($mbxcount)." $attachment = "c:\scripts\mailboxes.htm" SendMail($Recipient) #End Many thanks in advance, Graig
October 20th, 2010 9:38am

In fact leavers are moved in 2 OU: company.intra/Company/Old/Users/Graig uk.company.intra/Company/Old/Users/EG So I would need NOT to have the users belonging to the above OUs in my report. I hope that is possible. Graig
Free Windows Admin Tool Kit Click here and download it now
October 20th, 2010 9:40am

Hi, Please understand that we only discuss pure Exchange questions in this forum. Regarding to the Script to generate report question, I suggest you create a new thread in Script forum which can address your question more accurately and quickly. http://social.technet.microsoft.com/Forums/en/ITCG/threads/ Thank.Novak Wu-MSFT
October 24th, 2010 10:56pm

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics