locked
Running test-servicehealth from Excel list RRS feed

  • Question

  • 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?
    Saturday, March 19, 2011 1:46 PM

Answers

  • You will beed the PowerShell script and you do not require the Excel sheet as you can spacify the server in the script.

    Let me check the script for you.


    Gulab | MCTS-MCITP Messaging: 2010 | MCTS-MCITP Messaging: 2007 | MCC 2011 | Skype: Gulab.Mallah
    • Marked as answer by Joe Budden Sunday, March 20, 2011 2:34 PM
    Saturday, March 19, 2011 2:09 PM

All replies

  • You will beed the PowerShell script and you do not require the Excel sheet as you can spacify the server in the script.

    Let me check the script for you.


    Gulab | MCTS-MCITP Messaging: 2010 | MCTS-MCITP Messaging: 2007 | MCC 2011 | Skype: Gulab.Mallah
    • Marked as answer by Joe Budden Sunday, March 20, 2011 2:34 PM
    Saturday, March 19, 2011 2:09 PM
  • The easiest way would be to save the Excel data as a CSV file. Then use "import-csv" to get the names of the machines.

    import-csv names.csv | foreach{test-servicehealth -server $_.servername;test-mapiconnectivity -Server $_.servername}

    That little bit of Powershell doesn't, of course, address what you'll do with the output of the individual test-* cmdlets.


    --- Rich Matheisen MCSE+I, Exchange MVP
    Sunday, March 20, 2011 6:14 PM
  • import-csv names.csv | foreach{test-servicehealth -server $_.servername;test-mapiconnectivity -Server $_.servername}

    Looks good! Do you know how I could get the name of the server with the output so if there was a failure I would know what server failed?

    Thanks a lot.

    Sunday, March 20, 2011 6:23 PM
  • It seems very late for this Question but below is solution for detail with servername :-

    gc C:\server.txt |foreach-object {test-servicehealth -server $_ | Add-Member -MemberType noteproperty -Name Server -Value $_ -PassThru} | fl server, require*


    Regards, Sourabh Kumar Jha | Please mark it as an answer if it solves your problem or vote as helpful if you like it. |

    Friday, April 11, 2014 10:56 PM