So what have I got from this class? My inital goals were to take some Old VB scripts that I had written years ago for my Exchange 2003 project. I am working on translating and enhancing these reports. Certainly powershell makes this a Snap. Here is the first and most basic script. I want to get the WhiteSpace information out of a remote Exchange cluster 2003 server where powershell is not installed. This is my first cut at it and I will look at adding totals and more information soon. Stay tuned for a few more scripts....
# Setup the Eventlog for the application log on a Remote server
$log = new-object system.diagnostics.eventlog("application","ServerName")
# Prepare a table in HTML to house the information (Right from MS!)
$a = ""
#Prepare to generate a CDO message to email the report
$mail=new-object -comobject cdo.message
$mail.From = "report@mydomain.com"
$mail.To = "Someuser@mydomain.com"
$mail.Subject = "White Space report for " + $(get-date)
# Set the HTML body of the Email the actual report - This is the meat and potatos of it
$mail.htmlbody=$log.get_entries() where-object { $_.timewritten -ge (get-date).adddays(-1) -and $_.eventID -eq 1221}
select-object -Property EventID, MachineName, Message, TimeGenerated convertto-html -head $a -body "
PowerShell Whitespace Report for Exchange Cluster
"# Complete the email and send it out
$mail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
$mail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "smtpRelayServer@mydomain.com"
$mail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25
$mail.Configuration.Fields.Update()
$mail.send()
1 comment:
If you want the full code go to
Http://www.murmans.com/mostlymail/whitespacereport.txt
Post a Comment