Link to home
Create AccountLog in
Avatar of pchettri
pchettri

asked on

Is there a script to monitor Exchange 2013 and get daily email report of health?

Is there a script to monitor Exchange 2013 and get daily email report of health? I tried Paul's poweshell script but it only gives option for monitor when Exchange is up as powershell is using same SMTP to send email alert, which wont work if the services on server is down.

SCOM has been replaced with SCCM which means I might to deployed entire SCCM 2012 package to get the monitoring feature of Exchange and GSX might not be cost effective to monitor Exchange with only 2 DAB members
Avatar of Sudeep Sharma
Sudeep Sharma
Flag of India image

Hi PChetrri,

.......as powershell is using same SMTP to send email alert, which wont work if the services on server is down.............

Why don't you modify the script and send the email through gmail?

You just need to modify the email module.

Sudeep
Avatar of pchettri
pchettri

ASKER

I have used the link to create script and task. What I am trying to find out is how to add gmail as sender and receiving email address instead of Exchange. How does the authentication happens, if I am using gmail as sender too.

I have had success with Steve to get HTML but I had issues with Paul to get in HTML though it does show in powershell correctly. I have been trying fix that for couple of days. I may have to post of paul's forum with error. I did have to change exchanger server powershell virtual link to constant entry instead of using call method to make Paul's method at least in powershell. For Steve it does not work in remotesigned and it has to be unrestricted
SOLUTION
Avatar of Mohammed Khawaja
Mohammed Khawaja
Flag of Canada image

Link to home
membership
Create an account to see this answer
Signing up is free. No credit card required.
Create Account
you mean call this script from existing report script for Exchange by Steve?
Does the above script needs to be saved as PS1 for email reporting to run?
All PowerShell scripts must be saved as .ps1.  From the original script, remove the part that tries to email re file with the new script or just have the first script save the report to a file and then use the second script to email.  I am not at a PC but I could modify the script for you on Wednesday.
got it I have change the c:\Filename.FileType"  to original html report file
I am getting this error now, looks like gmail does not allow plain text password authentication -

Send-MailMessage : The SMTP server requires a secure connection or the client
was not authenticated. The server response was: 5.5.1 Authentication Required.
Learn more at
At C:\cert\email.ps1:12 char:1
+ Send-MailMessage -To $EmTo -From $EmFrom -Body $Bod -Subject $Subj
-Attachments  ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~
    + CategoryInfo          : InvalidOperation: (System.Net.Mail.SmtpClient:Sm
   tpClient) [Send-MailMessage], SmtpException
    + FullyQualifiedErrorId : SmtpException,Microsoft.PowerShell.Commands.Send
   MailMessage
SOLUTION
Link to home
membership
Create an account to see this answer
Signing up is free. No credit card required.
Create Account
I dont see the format for password in smtp credential information
This script has not worked yet
What error are you getting?

Sudeep
Actually, the script posted by Mohammed Khawaja is working after I disabled two factor authentication from gmail. I think your script was missing password variable to authenticate to gmail. Mohammed Khawaja has complete script for email only that I could use to call the report saved in C drive and it works with Steve get excahgehealth script
it would have been great, if you script has gmail authentication to send and receive the report in gmail
Password is credentials in the script.

$smtpsettings = @{
      To =  "administrator@exchangeserverpro.net"
      From = "your@gmail.com" //your gmail.com address goes here
      Subject = "$reportemailsubject - $now"
      SmtpServer = "smtp.gmail.com"
      Port = 587
    UseSsl = $true
    Credential  = 'you@gmail.com'       // your gmail credentials goes here
      }

Its there.

Sudeep
ASKER CERTIFIED SOLUTION
Link to home
membership
Create an account to see this answer
Signing up is free. No credit card required.
Create Account
My scripts run fine in powershell but it does not generate HTML or email. It only shows status directly on powershell.
I copied modified script from Sudeep but I started getting unnecessary error with comment section. So only copied and modified the email function call and reference to email section using my gmail account and authentication. Script runs fine without error, it just does not generate email or HTML
Hi Sudeep,

Have you really tested on gmail or external email, as  gmail wont work without plain text password conversion as done by Muhammad in previous comment and I get error


Exception calling "Send" with "1" argument(s): "The SMTP server requires a secure connection or the client was not
authenticated. The server response was: 5.5.1 Authentication Required. Learn more at"
At C:\scripts\paul-ExchangeServerHealth.ps1:2113 char:4

      if ($SendEmail)
      {
            if ($alerts -eq $false -and $AlertsOnly -eq $true)
            {
                  #Do not send email message
                  Write-Host $string19
                  if ($Log) {Write-Logfile $string19}
            }
            else
            {
                  #Send email message
                  Write-Host $string14
                  $message = New-Object System.Net.Mail.MailMessage
                  $message.Body = $htmlreport
                  $message.IsBodyHtml = $true
                  $message.subject = $emailsubject
                  $message.to.add($emailTo)
                  $message.cc.add($emailcc)
                  $message.from = $emailFrom
                  $smtp = New-Object System.Net.Mail.SmtpClient($SMTPServer, $SMTPPort);
                  $smtp.EnableSSL = $true
                  $smtp.Credentials = New-Object System.Net.NetworkCredential($Username, $Password);
                  $smtp.send($message)
Also, I have disabled all security from gmail and tried both port with and without SSL authetication
Sudeep Sharma  script finally worked it was authentication issue from gmail which worked after disabling feature and adding 587 port back with SSL authentication