Solved

Running test-servicehealth from Excel list

Posted on 2011-03-19
7
639 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
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 
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

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

Marketers need statistics and metrics like everybody else needs oxygen. In this article we explain how to enable marketing campaign statistics for Microsoft Exchange mail.
A procedure for exporting installed hotfix details of remote computers using powershell
In this video we show how to create an Accepted Domain in Exchange 2013. We show this process by using the Exchange Admin Center. Log into Exchange Admin Center.: First we need to log into the Exchange Admin Center. Navigate to the Mail Flow >> Ac…
In this Micro Video tutorial you will learn the basics about Database Availability Groups and How to configure one using a live Exchange Server Environment. The video tutorial explains the basics of the Exchange server Database Availability grou…

746 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now