Need info to existing script
Hello, Config: Microsoft Windows Server 2003, Enterprise Edition x64 - R2 Version 5.2.3790 ServicePack 2 Nu 3790 - Type x64 Microsoft Exchange Environnement: Exchange Server 2007 Microsoft Corporation - Version : 08.01.0263.000 **** 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 What I miss in that report is: The total amount of mailbox INCLUDED in the html file. the ProhibitSendReceiveQuota the ProhibitSendQuota the Database and the SamAccountName I am not good enough to include those data in the script and I am not even sure it would be possible. Therefore I would really appreciate your help if you could help me out to insert those data. In fact that statistic report is sent automoticaly and it is so great not to worry about it :-) Hope that we could figure out something. Thanks to all in advance for your input.
May 20th, 2010 4:19pm

Hi, First of all you need to comebine outputs from 2 cmdlets. Second you need to create a ForEach loop from a txt file or a user query (selection). --- What I miss in that report is: *** Foreach loop -> add a counter to get the total amount of mailboxes. The total amount of mailbox INCLUDED in the html file. *** These outputs are from the get-mailbox cmdlet. the ProhibitSendReceiveQuota the ProhibitSendQuota the Database and the SamAccountName --- Here is something where you can start with. Pls "don't copy paste this in PS and run it" !!!, its not complete. *** $UserList = Get-MailboxStatistics | Sort-Object TotalItemSize -Descending | Get-Mailbox | Select Alias $MailboxCounter = 0 ForEach ($User in $UserList){ $MailboxCounter = $MailboxCounter + 1 Get-mailbox $user | Format-Table DiplayName, SamAccountName, @{l="TotalItemSize(KB)";expression={(get-MailboxStatistics -Identity $_Alias).TotalItemSize.Value.ToKB()} ,@{label="ItemCount";expression={(Get-MailboxStatistics -Identity $_.Alias).ItemCount}}, ProhibitSendReceiveQuota, ProhibitSendQuota, Database -Autosize | Out-File c:\Statistics.txt -append -Width 700 } $TotalMailboxes = "Total Mailbox Counted ="+ $MailboxCounter +"" $TotalMailboxes | Out-File c:\Statistics.txt -append *** So its up to you to do the html convertion (from the out-file part of the script) but that won't be the hardest part cause if you combine you script with this one you will manage it. I think combining the 2 outputs is the hardest part, and you got that now :-) Try to take out parts by parts and test it... Greetzz, Timmy
Free Windows Admin Tool Kit Click here and download it now
June 3rd, 2010 11:29am

Hello, Thank you very much for your input. I do not have a test environnement and as long as you mentionned not to run the script you worte, I won't know if it would suits me. I would not mind not using the html format.
June 14th, 2010 12:18pm

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

Other recent topics Other recent topics