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
Exchange

Avatar of undefined
Last Comment
pchettri

8/22/2022 - Mon
Sudeep Sharma

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
Mohammed Khawaja

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
I started with Experts Exchange in 2004 and it's been a mainstay of my professional computing life since. It helped me launch a career as a programmer / Oracle data analyst
William Peck
SOLUTION
Mohammed Khawaja

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
pchettri

ASKER
you mean call this script from existing report script for Exchange by Steve?
pchettri

ASKER
Does the above script needs to be saved as PS1 for email reporting to run?
Mohammed Khawaja

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.
⚡ FREE TRIAL OFFER
Try out a week of full access for free.
Find out why thousands trust the EE community with their toughest problems.
pchettri

ASKER
got it I have change the c:\Filename.FileType"  to original html report file
pchettri

ASKER
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
Sudeep Sharma

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
⚡ FREE TRIAL OFFER
Try out a week of full access for free.
Find out why thousands trust the EE community with their toughest problems.
pchettri

ASKER
I dont see the format for password in smtp credential information
All of life is about relationships, and EE has made a viirtual community a real community. It lifts everyone's boat
William Peck
pchettri

ASKER
This script has not worked yet
Sudeep Sharma

What error are you getting?

Sudeep
pchettri

ASKER
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
⚡ FREE TRIAL OFFER
Try out a week of full access for free.
Find out why thousands trust the EE community with their toughest problems.
pchettri

ASKER
it would have been great, if you script has gmail authentication to send and receive the report in gmail
Sudeep Sharma

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
Sudeep Sharma

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
⚡ FREE TRIAL OFFER
Try out a week of full access for free.
Find out why thousands trust the EE community with their toughest problems.
pchettri

ASKER
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
Experts Exchange has (a) saved my job multiple times, (b) saved me hours, days, and even weeks of work, and often (c) makes me look like a superhero! This place is MAGIC!
Walt Forbes
pchettri

ASKER
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)
pchettri

ASKER
Also, I have disabled all security from gmail and tried both port with and without SSL authetication
pchettri

ASKER
Sudeep Sharma  script finally worked it was authentication issue from gmail which worked after disabling feature and adding 587 port back with SSL authentication
⚡ FREE TRIAL OFFER
Try out a week of full access for free.
Find out why thousands trust the EE community with their toughest problems.