Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

Professional Opinions
Ask a Question
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE

troubleshooting Question

Running test-systemhealth | out-File "C:\smtptest.txt" returns me a blank file?

Avatar of technolutions
technolutionsFlag for South Africa asked on
3 Comments1 Solution1039 ViewsLast Modified:
I'm just starting out in the world of powershell scripting and I'm working on a script to run "test-systemhealth" on exchange, chuck the output of that into a txt file and e-mail it to me. That way I can schedule it to run every morning and I can check if my server is fine each morning while sipping away at my coffee. Find attached the code draft for my script.

Problem: everything works but when I run test-systemhealth | out-File "C:\smtptest.txt" it gives me the following message in powershell and I'm left with a blank txt file:

Test-SystemHealth : Database 'Mailbox Database' on server SEMI contains 18 mail
boxes. This database has never had a full online backup.
At line:1 char:18
+ test-systemhealth  <<<< | out-File "C:\smtptest.txt"
Test-SystemHealth : Database 'Public Folder Database' on server SEMI has never
had a full online backup.
At line:1 char:18
+ test-systemhealth  <<<< | out-File "C:\smtptest.txt"
Test-SystemHealth : The Microsoft Exchange System Attendant process on server S
EMI is configured to interact with the desktop. This configuration should only
be used under the guidance of Microsoft Product Support Services.
At line:1 char:18
+ test-systemhealth  <<<< | out-File "C:\smtptest.txt"
test-systemhealth | out-File "C:\smtptest.txt"
$SMTPserver = "server.domain.local"
$fileattachment = "c:\smtptest.txt"
$from = "administrator@blah.com"
$to = "me@blah.com"
$subject = "Mail Test"
$emailbody = "Morning Server Test"
$mailer = new-object Net.Mail.SMTPclient($SMTPserver)
$msg = new-object Net.Mail.MailMessage($from, $to, $subject, $emailbody)
$attachment = new-object Net.Mail.Attachment($fileattachment)
Avatar of BSonPosh
BSonPoshFlag of United States of America image

Our community of experts have been thoroughly vetted for their expertise and industry experience.

This problem has been solved!
Unlock 1 Answer and 3 Comments.
See Answers