Solved

Running test-servicehealth from Excel list

Posted on 2011-03-19
7
650 Views
Last Modified: 2012-06-27
Hi

I have a list of 20 Exchange 2007 servers in Excel that are going to be rebooted this evening.

I would like to run test-servicehealth and test-mapiconnectivity against them tomorrow morning. Rather than typing each one out manually, I'd like Powershell to be able to grab them from the Excel sheet and run through each one.

Does anyone know how I would do this?
0
Comment
Question by:bruce_77
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 3
7 Comments
 
LVL 13

Accepted Solution

by:
soostibi earned 500 total points
ID: 35171731
The test-servicehealth cmdlet has a -server parameter, so you can use the following structure to make the test from any Exchange box or workstation that has the Exchange Management Tools installed. I recommend to put the serverlist into a TXT file or a CSV. Reading directly from an XLS is more complicated.

get-content c:\serverlist.txt | foreach-object {test-servicehealth -server $_}

Of course you can customize the test-searvicehealth part accourding to your needs.

The test-mapiconnectivity requires databases or mailboxes as an input to test:

get-content c:\databases.txt | foreach-object {test-mapiconnectivity -database $_}
or
get-content c:\mailboxestotest.txt | foreach-object {test-mapiconnectivity -identity $_}

Of course, here you have to customize the rest of the test-mapiconnectivity part accourding to your needs.
0
 
LVL 2

Author Comment

by:bruce_77
ID: 35175113
That's great, thanks very much.

For this: get-content c:\serverlist.txt | foreach-object {test-servicehealth -server $_}

I can see the servers and the results of test-servicehealth, but is there any way to return the name of the servers too, so if there is a failure on one I know which one it is?
0
 
LVL 13

Expert Comment

by:soostibi
ID: 35175239
Unfortunately I have only Exchange 2010, so I can not check, if the result will be OK for Exchange 2007, but here is my try:

get-content c:\serverlist.txt | foreach-object {$s = $_; test-servicehealth -server $s | select-object -property *, @{n="Server";e={$s}}}

0
Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

 
LVL 4

Expert Comment

by:Habeebmast7
ID: 35178937
You can direct feed the Exchange servers without the server with the below command.
Get-ExchangeServer | Test-ServiceHealth

Would have to check how we get the name of the servers though....this will only give you the role of the server.

- Habz
0
 
LVL 2

Author Comment

by:bruce_77
ID: 35183368
Thanks both

As regards this line here:

get-content c:\serverlist.txt | foreach-object {$s = $_; test-servicehealth -server $s | select-object -property *, @{n="Server";e={$s}}}


Isn't there an easier way to get the name of the server than this? Surely a get-server somewhere in there would work?
0
 
LVL 13

Expert Comment

by:soostibi
ID: 35183535
Check if the output of
test-servicehealth -server $s | fl *

includes any line, with the servername in it. If not, there is no easier way to do. (In Exchange 2010 the servrename is there.)
0
 
LVL 2

Author Comment

by:bruce_77
ID: 35329052
Sorry- where should I enter this?
0

Featured Post

Does Powershell have you tied up in knots?

Managing Active Directory does not always have to be complicated.  If you are spending more time trying instead of doing, then it's time to look at something else. For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Windows 10 came with  a lot of built in applications, Some organisations leave them there, some will control them using GPO's. This Article is useful for those who do not want to have any applications in their image (example:me).
This article will help to fix the below error for MS Exchange server 2010 I. Out Of office not working II. Certificate error "name on the security certificate is invalid or does not match the name of the site" III. Make Internal URLs and External…
In this video we show how to create a Resource Mailbox in Exchange 2013. We show this process by using the Exchange Admin Center. Log into Exchange Admin Center.: Navigate to the Recipients >> Resources tab.: "Recipients" is our default selection …
how to add IIS SMTP to handle application/Scanner relays into office 365.
Suggested Courses

630 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question