Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 658
  • Last Modified:

Running test-servicehealth from Excel list

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
bruce_77
Asked:
bruce_77
  • 3
  • 3
1 Solution
 
soostibiCommented:
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
 
bruce_77Author Commented:
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
 
soostibiCommented:
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
Lessons on Wi-Fi & Recommendations on KRACK

Simplicity and security can be a difficult  balance for any business to tackle. Join us on December 6th for a look at your company's biggest security gap. We will also address the most recent attack, "KRACK" and provide recommendations on how to secure your Wi-Fi network today!

 
Habeebmast7Commented:
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
 
bruce_77Author Commented:
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
 
soostibiCommented:
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
 
bruce_77Author Commented:
Sorry- where should I enter this?
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 3
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now