Solved

Running test-servicehealth from Excel list

Posted on 2011-03-19
7
642 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
  • 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
NAS Cloud Backup Strategies

This article explains backup scenarios when using network storage. We review the so-called “3-2-1 strategy” and summarize the methods you can use to send NAS data to the cloud

 
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

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Learn to move / copy / export exchange contacts to iPhone without using any software. Also see the issues in configuration of exchange with iPhone to migrate contacts.
A procedure for exporting installed hotfix details of remote computers using powershell
To add imagery to an HTML email signature, you have two options available to you. You can either add a logo/image by embedding it directly into the signature or hosting it externally and linking to it. The vast majority of email clients display l…
how to add IIS SMTP to handle application/Scanner relays into office 365.

828 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